Basically "this" refers to the instance of the current class. So for a static class we cant create the instance. Hence we cant use.
we can't use "This" keyword in static method because we can able to use only static variable and methods.
No we cannot
Direct answer to the question is NO, we can't use This keyword with static method. Explanation: The purpose of THIS keyword is to point to an instance of a class i.e. object. Ex. For class vehicle, CAR is an instance which can be pointed using THIS keyword. Where as STATIC defines something common to all instances and becomes a TYPE. If everything is same in all instances why would you need to make a NEW instance of it. and that's how there is no use of THIS with STATIC.
"This" referes to current instance of a class. Since Static method is class member compiler will get confused about which instance we are trying to access
I think Yea we can use This in parameter for static method. For implementing the extension methods we use “This” in parameters.
Ex :public static class ExtMetClass { public static int IntegerExtension(this string str) { return Int32.Parse(str); } }
According to me you can use “this” keyword only with static method parameter but there is certain condition like class and method must be static and this method will be called extension method.
Visit - www.sudheshwertech.com for online dot net training. Thanks
No, we can't use 'this' keyword inside the static method bcz static class doesn't have instance. we can use this keyword as first parameter in static method.
I would like to first tell. This keyword points to current object of a class. So If you cannot create object of a static class then how can you use this. So the simple answer is we cannot use 'This' keyword in static method.
Basically "This" keyword is used for the instance members. As static methods are directly accessed by the class name and the method name we cannot use "This" keyword for static members.
No.This refer to current instance.For Static class you can not create instance.