[英]Reference method from another class in c#
So I have a class where I create a customer with all necessary information (addresses, phone, emails, etc...) Basically I want to create other classes that do other things with that customer information but reference that class to create a new customer each time. 因此,我有一个班级,在那里我用所有必要的信息(地址,电话,电子邮件等)来创建客户。每一次。
Here is an example of the class I need to reference: 这是我需要参考的类的示例:
public class Start_Customer
{
public CreateRequest _request;
public CreateResponse _response;
string fax = "(866) 345-3453";
string website = "www.testersRus.com";
bool Manage = true;
int PartnerID = 0;
string FirstName = "";
string LastName = "";
string Email = "";
public void CreateClient()
{
_request = new CreateRequest();
_request.CommandComment = "";
}
public void Test()
{
//create a new web service client
var sw = new SoapCreateStart();
_response = sw.Customers_Start(new AppHeader(), _request) as CustomerResponse;
Console.WriteLine(_response.ToString());
}
Now in my new class I am trying to use reference that class and make a new customer and then check and see if certain things were made like the fax number is correct, company is correct and things like that. 现在,在我的新班级中,我尝试使用该班级的参考并结识新客户,然后检查并确定是否做出了某些事情,例如传真号码正确,公司正确,以及诸如此类。
Any ideas on how to reference this the correct way WITHOUT making the methods static? 关于如何在不使方法静态化的情况下正确引用此方法的任何想法?
So far I was thinking that I would say: 到目前为止,我一直在想我会说:
Start_Customer create = Start_Customer();
create = CreateClient();
This lets me get to the method but I keep getting null error. 这使我可以使用该方法,但会不断出现null错误。 Help please! 请帮助!
Was able to figure it out. 能够弄清楚。 I had to reference each method by saying: 我不得不引用每种方法,说:
create.Create();
For example, thanks for the help! 例如,感谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.