TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326k
Using "this" Reference
Nov 30 2011 1:43 PM
It is said that using this reference can save memory. Can anyone please explin how "this" can save memory. Following one is a example program.
using System;
public class CreateStudent
{
public static void Main()
{
Student x = new Student();
x.SetId(951);
x.SetName("Ross");
x.SetGPA(3.5);
Console.WriteLine
("The student named {0} has ID # is {1} and a gpa of {2}", x.GetName(), x.GetId(), x.GetGPA());
Console.ReadLine();
}
}
class Student
{
private int id;
private string lastName;
private double gpa;
public int GetId()
{
return id;
}
public void SetId(int id)
{
this.id = id;
}
public string GetName()
{
return lastName;
}
public void SetName(string lastName)
{
this.lastName = lastName;
}
public double GetGPA()
{
return gpa;
}
public void SetGPA(double gpa)
{
this.gpa = gpa;
}
}
//The student named Ross has ID # is 951 and a gpa of 3.5
Reply
Answers (
6
)
Lamda expression to remove filename
C# tablelayout panel