Return Object of a Class from a Function in C#

Shubham
Posted by Shubham under C# category on | Points: 40 | Views : 1038
using System;

namespace knownnamespace
{
class Share
{
public int ShareNumber = 299;
}
class Programs
{
static void Main(string[] args)
{
Share ObjS = ObjFactory();

Console.WriteLine("The Return Object is: ");
Console.WriteLine(ObjS.ToString());
Console.WriteLine(ObjS.ShareNumber);

Console.ReadLine();
}

static Share ObjFactory()
{
Share objShare = new Share();
objShare.ShareNumber = 201;
return objShare;
}
}
}

Comments or Responses

Login to post response