Object Instantiation in C# Programming
I have a class Greet and I am creating a object of this class by following two ways. Could you suggest me, which one is best way or both are same from the memory allocation point of view.
Kindly suggest the answer from the memory allocation point of view
- class Greet
- {
- public string SayHello()
- {
- return "Hello Praveen";
- }
- }
- static void Main(string[] args)
- {
- string message = "";
-
- Greet greet = new Greet();
- message=greet.SayHello();
-
-
- message =new Greet().SayHello();
- }