Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

this in unity

The “this” keyword in C# is used to refer to the current instance of the class.
It is also used to differentiate between the method parameters and class fields
if they both have the same name

Example code:

using System;
 
namespace ThisKeyword {
  class Test {

    int num;
    Test(int num) {
      
      // this.num refers to the instance field
      this.num = num;
    }

    static void Main(string[] args) {

      Test t1 = new Test(4);
      Console.WriteLine("value of num: " +t1.num);
      Console.ReadLine();
    }
  }
}

// output:  value of num: 4
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# string array contains 
Csharp :: how to get hours and minutes from second in c# 
Csharp :: how get query from url in laravel 
Csharp :: c# array to list 
Csharp :: c# if statement one line 
Csharp :: c# remove double quotes from string 
Csharp :: c# make request to rest api 
Csharp :: c# day of week number 
Csharp :: c# ignore enter key 
Csharp :: log to console c# unity 
Csharp :: how to write int array to console c# 
Csharp :: C# decimal with two places store as string with two places 
Csharp :: c# print console 
Csharp :: if in dictionary c# 
Csharp :: dynamic arrays in c# 
Csharp :: c# string contains any of list 
Csharp :: change name of gameobject 
Csharp :: how to check if file contains image c# 
Csharp :: get last character of string c# 
Csharp :: fade image out unity 
Csharp :: unity ui movement 
Csharp :: string list to object array in c# 
Csharp :: c# select oracle database 
Csharp :: regex c# 
Csharp :: get index c# 
Csharp :: sequelize count all 
Csharp :: datatable to array c# 
Csharp :: Convert DataTable to Dictionary in C# 
Csharp :: c# create tasks and wait all 
Csharp :: c# function return 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =