Link to home
Start Free TrialLog in
Avatar of Skale
Skale

asked on

Using 'this' statement in static method pros/cons in C#

Hello,

I'm using a static method to get information from COM object like;

public static string GetBodyName(this IScrBody obj) { //some code}

With that i'm able use it like;

var myBodyName = Body.GetBodyName()

in before i'm using like that;

public static string GetBodyName(IScrBody obj) { //some code}

and i'm trying to return a value

var myBodyName = GetBodyName(obj)

Now i've search on net but didn't find like i expected.

Now i'd like to know are there any pros/cons of using this statement.

I really need expert's advice.

Any help would be great!
Thank you.
SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Skale
Skale

ASKER

Hi Chinmay,

My question is about difference between them where to use, where to don't use pros/cons

public static string GetBodyName(IScrBody obj) { //some code}
public static string GetBodyName(this IScrBody obj) { //some code}

Open in new window

this IScrBody obj
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial