Results 1 to 7 of 7

Thread: 'this' keyword of C sharp

  1. #1
    Join Date
    Dec 2009
    Posts
    37

    'this' keyword of C sharp

    Hello Friends,

    According to me C sharp programming is very challenging than any other programming languages. Here I need your help to understand the one important concept of the C sharp programming. I want to know about the 'this' keyword of C sharp programming. What is the use of 'this' keyword in C sharp? If you have sound knowledge about the 'this' keyword of C sharp then please let me know that. I waiting for your reply.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: 'this' keyword of C sharp

    The 'this' keyword of C sharp programming is mostly used for referencing the instance of current class . 'this' keyword is also used as 'qualifier' while referencing the fields methods or fields properties of the current class instance. In short the this' keyword of C sharp is refer to the current class instance. The 'this' keyword is also essential to give intellisense support while the debugging of the class. 'this' keyword is also used as a parameter for the other class methods.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: 'this' keyword of C sharp

    Hi friend,

    The 'this' keyword of C# programming is used as an instance property or instance method which has reference to the current class instance. 'this' keyword is useful for defining the extension methods of the class. Extension methods of class enable you for extending the existing method types. If extension methods are static then it can be used as the normal methods of the extended class. So that you can add the new functionality to the existing class without the recompilation of the class.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: 'this' keyword of C sharp

    Example of the 'this' keyword of C sharp programming:
    class CHDemo
    {

    int b=21,d=15;

    public void GetD()
    {
    int b=83,d=94;

    Console.WriteLine("b={0} d={1}",this.b,this.d);

    Console.WriteLine("These are the class variables");

    Console.WriteLine("These are the local variables");

    Console.WriteLine("b={0} d={1}",b,d);
    }
    }

    class MnClass
    {
    static void Main(string args[])
    {

    Demo h= new Demo();
    h.GetD();

    }
    }

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    Re: 'this' keyword of C sharp

    Hi,

    'this' keyword of C sharp enables to make the use of intellisense during writing code within the class property or class methods. 'this' keyword represents the current object instance. The 'Static member functions' of the class doesn't contain the 'this' pointers in C sharp. 'this' keyword of C sharp is also used as access member from the current class instance methods, instance accessors as well as from the constructors. You need to use the dot operator to access the current value of the variables within the class.

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: 'this' keyword of C sharp

    Hello friends,

    I have following c sharp code which explains the exact use and declaration of the 'this' keyword in the C sharp language:
    public class Pn
    {
    public string FName { get; set; }

    public string LName { get; set; }

    public int ir { get; set; }

    public Person(string FsName,string LsName, int irn)

    {
    this.LName = LsName;

    this.FName = FsName;

    this.ir = irn;
    }
    }

  7. #7
    softtrickseo Guest

    Re: 'this' keyword of C sharp

    'this' keyword show the current object of the page
    like :

    we declare some variable,

    public class Pn
    {
    public string FName { get; set; }

    public string LName { get; set; }

    public int ir { get; set; }

    public Person(string FsName,string LsName, int irn)

    {
    this.LName = LsName;

    this.FName = FsName;

    this.ir = irn;
    }
    }

Similar Threads

  1. Sharp 007SH Hybrid An 3D Clamshell Android Phone by Sharp
    By jackalz in forum Web News & Trends
    Replies: 3
    Last Post: 22-05-2011, 07:28 AM
  2. Keyword Analyzer and keyword ranking tool
    By Captain Carrot in forum Technology & Internet
    Replies: 5
    Last Post: 21-06-2010, 03:12 PM
  3. Best Keyword Tracker
    By Asclepius in forum Technology & Internet
    Replies: 5
    Last Post: 22-04-2010, 11:54 AM
  4. keyword Tracker for ASP?
    By Muses in forum Technology & Internet
    Replies: 5
    Last Post: 22-04-2010, 10:58 AM
  5. Replies: 3
    Last Post: 09-01-2009, 01:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,370,775.81820 seconds with 17 queries