/Home /Archive /Syndicate /About /Contact  
CSharpFeeds - All C# Feeds in One Place!





In Part Two I asked a couple of follow-up questions, the first of which was: Suppose you were a hostile third party and you wanted to mess up the parenting invariant. Clearly, if you are sufficiently trusted, you can always use private reflection or unsafe code to muck around with the state directly, so that's not a very interesting attack. Any other bright ideas come to mind for ways ... [ read more ]


In the previous posts I've presented some of the basic features introduced by the new LINQ To XML API. Today, we'll keep digging and I'll show you several options available for working with XML documents. As we've seen in the other day, documents are represented by instances of the XDocument class. You'll really need to use a XDocument when you need to load a DTD or when y ... [ read more ]
I interviewed a couple of college students earlier this week for internship positions with Lake Quincy Media , and one of them reminded me of my own college days when we were graded in part based on how well commented our code was.  In school, comments are typically there as a "check the block" measure to ensure that the professor doesn't take off points for not having them, b ... [ read more ]


In the previous post I've talked about some of the classes you'll find in this new API. Today we'll see how easy it is to create a new XML document with the new API. Most of the time, you'll end up working with the XElement or XAttribute classes. Lets start with an existing XML tree: <clients>   <client id="1">     <name>Luis ... [ read more ]


I've just started doing some LINQ To XML and I can assure you that the new API is really great! Just take a look at the new Object Model introduced by the System.XML.Linq assembly: Today I'll just cover the basics (really a quick presentation of the most important elements you can find in the new API), but I'm thinking on writing more posts on this subject. XObject is the top ... [ read more ]


Every once in a while when I write code that deals with Anonymous Delegates, I still kinda freak out when it comes to the behavior of closures and the variable scoping that goes along with it. For example, the following code uses a List<T>.Find() Predicate to search for items in the list and requires that a dynamic value is compared to: public void AddScript( ScriptItem script) { ... [ read more ]


.NET 2.0 introduced Nullable value types. As you surely know by now, you cannot set a value type to null. Here's an example: Int32 myVar = null; //error: myVar cannot be set to null This can be easily solved by transforming myVar into a Nullable type: Nullable<Int32> myVar = null; If you prefer, you can apply the ? suffix to the variable type: Int32? myVar = null; Nullable v ... [ read more ]


Holy goodness, I've been busy. The MVP Summit was fabulous for us; thanks to all who attended and gave us great feedback on our ideas for evolving the languages and tools. And I've been doing some longer-lead thinking and working on language futures, which I will blog about at a later date. Last time I promised another oddity of "protected" semantics. An issue that I get asked about all ... [ read more ]
I'm not that much a fan of fluent interfaces , but in some cases they are well fit. A great example is the fluent repeater created by Adrian Aisemberg. It's also a good example if you don't know what a fluent interface is. Here is sample code that uses it: Repeat.Call<string>(Save).WithParameters("myfile.txt").UntilSucceeds.Start(10); Repeat.Call(Ping).PauseBetweenCalls(2000).Start( ... [ read more ]


I’ve been looking deeply into FOAF lately and last week I worked on a parser that could wrap a FOAF document into a strongly typed class for easy consumption by C#. Now I want to share it with anyone interested. It appears there are no FOAF parsers available in C# yet. I wasn’t able to find any. The parser The class FoafParser has two public methods, Parse and ParseFriend ... [ read more ]


In my constant search for making it easier to write tests for common things in our framework, I believe I was able to clear some things up by using extension methods. Not that this hasn't been done before, it's just that I want to document how I got to it so that I can use this post to explain the approach to other people (and maybe help somebody else learning about this).  :) The scenario is: w ... [ read more ]
Note: Code in italics is not actual C# 3.0 syntax. Local Variable Type Inference C# 3.0 brought us local variable type inference mainly because of LINQ . The output of a query can vary from an IEnumerable<T> or an IQueryable<T> to a single instance of T where T can even be a projection which means that its type is an anonymous type. Take the following query as an ex ... [ read more ]


Last week, good pal Rod Paddock asked me an interesting question about LINQ, and I think this may be useful to others (not that the answer may not already be out there somewhere, of course...). The main scenario was that different queries had to be run depending on some options. The from and select parts of the query where pretty much the same; the parts that varied were the where and o ... [ read more ]



All feed content is property of original publisher. Designated trademarks and brands are the property of their respective owners.