Working with IP addresses in C#
And here’s the full example with a method to check whether an IP address is local: http://www.csharp-examples.net/local-ip/
And here’s the full example with a method to check whether an IP address is local: http://www.csharp-examples.net/local-ip/
To get the value of a private field of an instance in C#: Similarly, you can quite easily retrieve the value of a const or static field for a type, simply replace BindingFlags.Instance with BindingFlags.Static and call GetValue with null:
Whilst fishing around StackOverflow for interesting discussions I came across this question on which programming paradigm is best for which job. There were some interesting arguments put forward, and after doing some more reading here are the two things I took away: Language != Paradigm What paradigm (procedural, OO or functional, etc.) you choose to program …
The term ‘duck typing’ is often used to describe a type of dynamic typing in programming languages where the object’s current set of methods and properties determines the valid semantics. Why? duck test – If it looks like a duck, swims like a duck and quacks like a duck, then it probably is a duck
As you’re probably aware of already, LINQ comes in two flavours – using Lambda expressions and using SQL-like query expressions: Both yields the same result because query expressions are translated into their lambda expressions before they’re compiled. So performance-wise, there’s no difference whatsoever between the two. Which one you should use is mostly personal preference, …
In the last couple of days or so I have spent some time reading Karl Seguin’s excellent and FREE to download ebook – Foundations of Programming which covers many topics from dependency injection to best practices for dealing with exceptions. The main topic that took my fancy was the Back to Basics: Memory section, here’s …
If you’ve used events in C# before, you’ve probably written code like this too: This is perfectly ok and normal to do, but can quickly become tiresome if you have to fire events in multiple places in your code and have to do a null reference check every time! So instead, I have been using …
Pattern for dealing with null handler for events in C# Read More »
Over the last couple of days I have read a number of blogs on the topic of covariance and contravariance, a new feature to be introduced in the upcoming C# 4.0 release. Whilst most of the blog posts were happy to provide a detailed account of what these terms mean and provide some simple examples, …
As I was learning functional programming with F# I came across the List.reduce function which iterates through a list and builds up an accumulator value by running another function against each element in the list. Back to the more familiar C# territory, LINQ has introduced some functional features to C# and one of these is …
Functional programming with Linq – IEnumerable
For a hex literal that’s not prefixed you can quite easily convert it using int.Parse in C#: But as you’ve probably noticed, most hex literals are prefixed with 0x (e.g. “0x142CBD”) which would throw a FormatException if you try to parse it using the above code. In order to parse a 0x prefixed hex literal …
By continuing to use the site, you agree to the use of cookies. more information
The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.