Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Public Field - why is it bad?

$
0
0

I'm a C# novice.

I was at a Microsoft event recently and the presenter showed this line of code from Azure Mobile Services:

public static Microsoft.WindowsAzure.MobileServices.MobileServiceClient myMobileClient = new Microsoft.WindowsAzure.MobileServices.MobileServiceClient("https://devconmobiledemo.azure-mobile.net/", "ZUKbKijeweoinOIJwoivhe0t94");

He said it was bad because it was "implemented as a public field, but we'll just put up with it even though it's not great practice".

What did he mean? I don't have the C# understanding to untangle what that meant. I don't understand what the keyword "static" is doing to this object? And isn't that just a constructor tacked on to the end? All it does is set up the way to connect to the mobile services endpoint? There's nothing to suggest it's a public field - is there?

Can anybody explain what he meant? In gentle novices language!!!?

Thanks

Curious...


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>