The second will have to be:
public void SomeFunction, string firstname, stringlastname, ref MyObject obj)
{
obj = new MyObject(firstname, lastname);
}
so hte MyObject refernce can be changed
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Either create your method to return the object, like:
public MyObject SomeFunction(string firstname, string lastname)
{
return new MyObject(firstname, lastname);
}
Or, if you are returning a different type, for whatever reason, since
objects are reference types, just pass the object type in:
public void SomeFunction, string firstname, stringlastname, MyObject obj)
{
obj = new MyObject(firstname, lastname);
}
HTH
Dale Preston
MCAD, MCDBA, MCSE
NicK chlam via DotNetMonster.com said:
is thier any way to create a new object in a function and return that
object being able to use it in the main class?
like to have a static method that inputs first and last names, creates a
object and returns it?
[microsoft.public.dotnet.languages.csharp]