.net

How can I XML Serialize a DateTimeOffset Property?

The DateTimeOffset property I have in this class doesn't get rendered when the data is represented as Xml. What do I need to do to tell the Xml serialization to render that proper as a DateTime or DateTimeOffset? [XmlRoot("playersConnected")] public class PlayersConnectedViewData { [XmlElement("playerConnected")] public PlayersC...

GridView cell Date Format

I want to format Date of the GridView Cell text like ddMMMYYYY (i.e) 07MAY2010 how to achieve this? RowDataBound() { .... e.Row.Cells[10].Text = ......? } ...

Linq query preferences

Hi, Learning a bit about Linq. I have the following code: (Please excuse the pathetic size of the data set) class Program { static void Main(string[] args) { var employees = new List<Employee> { new Employee { ...

Will the .NET JIT inline a small function that calls another small function?

I would like to know - will the .NET JITter recursively inline small functions called from other small functions? Just for example: public static float Square(float value) { return value * value; } public static float Cube(float value) { return Square(value) * value; } If I call Cube from somewhere, will it inline all the wa...

If I target .NET 2.0, can I still get runtime features from newer versions?

I'm pretty pleased with targeting .NET 2.0 for my XNA games on the basis that it is more widely available (and I can still use nice C# 3.0 language features). But I recently came across an article saying that the .NET 3.5 SP1 JIT added inlining of value-type methods (something that, as a game developer, I use a lot of). So my question ...

Mixing multiple live MMS streams (mms://server) using expression encoder SDK

Expression encoder SDK can accept sources from a LiveDeviceSource or from a LiveFileSource, but both can't support mms streams. The question is, is there a way to include a live mms stream in an encoding LiveJob? And then, possibily a way to mix them and stream it? ...

Generate Database / Entity Data Model from C# Classes

I have been using Subsonic with MVC.NET and love the feature that allows me to generate a database from the c# classes. This is great because it allows you to think about the app first and the data second. Now that I am moving onto MVC.NET 2.0 - I am using the features in the Entity Framework which are great giving form validation clien...

C# multiple patterns in regex.replace()

Hi, How can i pass multiple patterns to the regex.replace() pattern parameter? In PHP you just give up the array containing them. Is there some kind of same option in C#? I'm looping through some usernames and some of those usernames are surrounded by html tags. The html tags are not all the same. But i do know which ones they are. S...

How to invoke (non virtually) the original implementation of a virtual method?

I have the following situation: In a 3rd party library (can not be modified): class A { public virtual void M() {} } class B : A { public override void M() {} } In my own code: class C : B { public override void M() {} } From C's implementation of method M I want to call A's (but not B's!!). Can I? Any tricks accepted, reflectio...

Create a class type in code in .net c#

When I was looking to the System.Linq.Expression capabilities (creating expression trees in code, compiling them, executing them) I was asking myself if this is possible for class creation as well - specifically generic classes. I would expect something like Expression.Class() or Expression.GenericClass(). Looking at the methods I did n...

Custom Sorting in .NET

I have designed a Class for Parent Child relationship class Category { public string CatName; public string CatId; public IList<Category> childCategory = new List<Category>(); public void addChildCat(Category childCat) { this.childCategory.Add(childCat); } public Category SortedCategory(Category ...

Large array and multiple threads - spinlocks or local buffers or something else?

I have an array with 250k entities (with a size of 20 bytes) and 4 threads. Each thread modifies ~100k random entities (that means, you can't predict which entities it will touch). It can modify the same entity multiple times. Each entity gets modified up to ~10 times. The modification takes ~10-6 seconds. Each entity gets modified by m...

regular expression

can some tell how can i write regular expression matching abc.com.ae or abc.net.af or anything ,ae which is the last in the string is optional this is successfull with / but not . don't know why ^[a-z]{1,25}.[a-z]{3}$ answer ^[a-z]{1,30}\.[a-z]{3}((\.)[a-z]{2})?$ ...

Identify the language and compiler used to create an assembly?

I would like to identify the language(C#, VB, whatever) used to create a particular assembly. I would also like to identify the compiler (the MS one, mono). There doesn't seem to be any information in the assembly. The section about the headers of an assembly in Ecma-335 partition II doesn't mention anything useful. I wonder if there ...

WPF - how to change XAML and get an immediate view of the affect in VS2010 without compiling/running?

Is there a way to get an immediate feedback/view of the impact of changing XAML in a WPF application? i.e. without having to recompile/run? In VS2010. In particular I ask this as I'm using the Charting from the WPF Toolkit library, and I'd like to be able to see the change in the UI I make after changing various charting sytles et...

GetType in .NET Reflection does not work

I'm trying to call Type.GetType("System.Diagnostics.TraceFilter") not typeof(System.Diagnostics.TraceFilter) but the result is always null. Could anyone help me out? How to get class type for this abstract class? ...

Create a Visual Studio 2010 like splash screen

Hello, I was intending to create a Splash screen like the one sported by Visual Studio 2010 for my desktop application (feel free to use any version of C#/VB/CLR). As per the Visual Studio blogs, the splash screen was not developed using WPF since it would involve the CLR and WPF libraries to load causing a substantial delay in app l...

ASP.Net MVC 3 - Html Extensions...

Hey guys I'm playing around with Razor + MVC 3 and have a really simple scenario... Basically I'm trying to create a very basic HTML helper but I'm getting the following exception: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'ScriptCss' and no extension method 'ScriptCss' accepting a first argument of type...

RavenDB. How to load document with only 5 items from inner collection?

Here is a document in the store: { "Name": "Hibernating Rhinos", "Employees": [ { "Name": "Ayende" }, { "Name": "John" }, { "Name": "Bob" }, { "Name": "Tom" }, { "Name": "Lane" }, { "Name": "Bill" }, { "Name": "Tad" } ] } It is easy to load this document with or wit...

How to override S#arp architecture automapping with HBM files?

I'm facing problems with composite keys in S#arp architecture. Anyone have an example of how to do that or how to use mapping files with automapping? ...