Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

[.net] Useful/obscure .Net classes

This topic is 4073 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been tasked with a doing small learning session at work (less than 10 people, maybe 15 minutes). I was thinking that often times people may write code to perform tasks already covered by classes within the .Net framework. So I thought I'd present a few .Net classes that people may be not be aware of that might prove useful in their every day lives. I'd just present the basics of the class, what it does, some of its more useful methods, maybe some of its downfalls, and a small example. So does anyone have any suggestions? Examples of classes (or interfaces or whatever) that make your coding life easier in one way or another? They don't have to necessarily be obscure or necessarily the most absolutely useful thing in the world. Just something that people may not know about that might take some time and effort out of their work? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Depending on what kind of projects/How many people work o differet projects, you might want to present MSBuild and the accompanying classes.

There's also a whole slew of cool stuff in System.Diagnostics. Stuff like DebuggerDisplayAttribute can be useful if you end up debugging a given type a lot and looking for the same info often.

Share this post


Link to post
Share on other sites
Thanks Jfclavette. I'll look into System.Diagnostic and MSBuild. Any others to look into? I was thinking maybe System.Collections and doing a run-down of the advantages of different containers.

Share this post


Link to post
Share on other sites
I find that a lot of programmers aren't aware/proficient at using .Net Serialization and often recreate their own serialization framework.

Share this post


Link to post
Share on other sites
I would avoid System.Collections and instead work on System.Collections.Generics. The generic collection classes are much neater and more type safe (and if you do need to have a variable type container, you can always explicitly use Object).

If they have used C/C++ a lot, then this construct would be familiar:

enum AnEnum
{
Item1,
Item2
};

const char *const AnEnumNames [] =
{
"Item1",
"Item2"
};

which you'd use a lot for loading/saving data. In .Net (this is the C++/CLI version):

enum class AnEnum
{
Item1,
Item2
};

for each (String ^item_name in Enum::GetNames (AnEnum::typeid))
{
// item name is the string form of the enum value
}

AnEmum enum_value = AnEnum::Item2;
String ^enum_value_name = enum_value.ToString ();

And finally with enums, don't forget the FlagsAttribute specifier for enums.

Don't use the form designer in DevStudio - it produces horrible code, especially with C++/CLI source. It also doesn't support localisation. And it's in code which requires a recompile to make changes. Consider building a XAML type system, i.e. a data driven framework for form design.

Can't think of anything else off the top of my head.

Skizz

Share this post


Link to post
Share on other sites
Quote:
Original post by benryves
System.CodeDom and System.CodeDom.Compiler can be used to parse source files and compile them into assemblies - couple this with System.Reflection to load the output and you can create scriptable applications quite easily.


Not forgetting of course to ensure the source of the script is trusted, i.e. it hasn't been sent to your web server from a HTTP POST request.

Skizz

Share this post


Link to post
Share on other sites
I (with a bit of direction stumbled across the Dictionary and found it to be quite useful. I also second intrest86's suggestion of serialization.

Share this post


Link to post
Share on other sites
You might want to go into some of the neat tricks you can do with reflection if they're people coming from C/C++. For me it was the kind of thing I would never, ever use unless some one showed me what it could do since the whole concept doesn't make any sense to a C/C++ programmer.

I also have fun writing sloppy code all over the place with anonymous delegates. Making a whole new method is just so tiresome sometimes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!