Interviews5 answers
Can we use "this" command within a static method?
5 Answers
No,we cannot use this command in static class , because this command is used to describe the current object instance of that class and since we cannot create instances of static class,hence it is not possible.
mohammed yaseenPosted May 2, 2021, 6:53 AM EDT
We cant access the static method with this instance. We can use type name to access the method.
Shekhar KumarPosted Jan 5, 2021, 5:02 AM EST
No, “this” command cannot be used with static method. Reason, this is used with instance ad static method can’t be used with any instance.
shashi shekharPosted Dec 11, 2020, 5:10 AM EST
this refers to current instance, static is a modifier that makes prevents from using class/method as part of instance. Hence, it will not work.
Varun SetiaPosted Oct 14, 2020, 7:28 AM EDT
No, we can’t use “this” keyword inside a static method.
“this” refers to current instance of the class. But if we define a method as static , class instance will not have access to it, only CLR executes that block of code. Hence we can’t use “this” keyword inside static method.
Kiran MohantyPosted Oct 5, 2020, 9:23 PM EDT




