In a code review, I stumbled over this (simplified) code fragment to unregister an event handler:
Fire -= new MyDelegate(OnFire);
I thought that this does not unregister the event handler because it creates a new delegate which had never been registered before. But searching MSDN I found several code samples which use this idiom.
So...
I would like to know how to get the name of the property that a method parameter value came from. The code snippet below shows what I want to do:
Person peep = new Person();
Dictionary<object, string> mapping = new Dictionary<object, string>();
mapping[peep.FirstName] = "Name";
Dictionary<string, string> propertyToStringMapping = Conver...
What's the secret to getting ClaimsResponse working with DotNetOpenId?
For example, in this bit of code (from Scott Hanselman's blog) the ClaimsResponse object should have lots of nice little things like 'nickname' and 'email address', but the ClaimsResponse object itself is 'null':
OpenIdRelyingParty openid = new OpenIdRelyingParty()...
What I want to do is something like this:
Button btn1 = new Button();
btn1.Click += new EventHandler(btn1_Click);
Button btn2 = new Button();
// take whatever event got assigned to btn1 and assign it to btn2
btn2.Click += btn1.Click; // compiler says no
where btn1_Click is already defined in the class:
void btn1_Click(object sender, ...
When using strongly typed dataSets in Visual Studio 2005/2008, if the underlying database schema changes, the only practical way to refresh is to delete the dataset and recreate it from scratch. This is OK unless I need to customize the dataset.
Customizing by extending the partial dataset class allows customizations to be retained, b...
The recently announced managed extensibility framework (MEF) of .NET 4.0 - is it a dependency injection framework? Will Microsoft Unity from Patterns and Practices be obsolete in 4.0 ? How does MEF compare to a framework like Unity?
...
So standard Agile philosophy would recommend making your domain classes simple POCOs which are Persisted using a separate proxy layer via data access objects (like NHibernate does it). It also recommends getting as high unit test coverage as possible.
Does it make any sense to write tests for these simple POCO objects? Say I have a c...
I love Visual Studio about 90% of the time, but that last 10% it is such a PITA it makes me want to launch my monitor off the desk.
My latest annoyances:
It won't remember my toolbar settings. I don't want any toolbars, ever. Quit popping open the CSS editor or XML editor or text editor everytime I open a file.
Doesn't remember which ...
I'm relatively new to .NET programming (and OOP in general) and I want to make sure I'm not developing bad beginner habits when designing my applications.
If you were hiring a new .NET developer and had to get him up to speed relatively quickly, but also wanted to make sure he adopts best practices (e.g., single responsibility principle...
I'm writing an application that includes a plugin system in a different assembly.
The problem is that the plugin system needs to get application settings from the main app (like the directory to look for plugins).
How is this done, or am I going about this the wrong way?
Edit: I was encouraged to add some details about how the plugin ...
In the early days of .Net, I believe there was an attribute you could decorate a class with to specify a default property.
According to some articles I've found, this appears to have been yanked from the framework at some point because it was a little confusing, and I can see how that is the case.
Still, is there another way to get th...
I'm using C# and .NET 3.5. I need to generate and store some T-SQL insert statements which will be executed later on a remote server.
For example, I have an array of Employees:
new Employee[]
{
new Employee { ID = 5, Name = "Frank Grimes" },
new Employee { ID = 6, Name = "Tim O'Reilly" }
}
and I need to end up with an array of ...
The "core" .NET languages are integrated into VS2008 - C#, VB.NET, and C++. I'm not sure about current support for J# and JScript.
But there are a number of other .NET languages out there - A#, Boo, Oxygene, F#, IronLisp/IronScheme, IronPython, IronRuby, Nemerle, Phalanger, P#, PowerShell, and more. Of these, I have only found VS suppor...
What's the best method to pass parameters to SQLCommand? You can do:
cmd.Parameters.Add("@Name", SqlDbType.VarChar, 20).Value = "Bob";
or
cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = "Bob";
or
cmd.Parameters.Add("@Name").Value = "Bob";
It seems like the first one might be somehow "better" either performance-wise or err...
I have a project on my plate that will involve a lot of linear algebra; mostly matrix and vector algebra. I've been looking for a library to help me out, and I came across math.net
http://mathnet.opensourcedotnet.info/
Math.net
I am doing this project in .net 3.5 and will be using C#
Does anyone have any experience with this librar...
I have an owner-drawn UserControl where I've implemented double-buffering. In order to get double-buffering to work without flicker, I have to override the OnPaintBackground event like so:
protected override void OnPaintBackground(PaintEventArgs e)
{
// don't even have to do anything else
}
This works great at runtime. The probl...
I want to do a little development in OSX and the iPhone. I've been a .Net/C# developer for years. I was wondering if there was anybody that had experience in both platforms that could tell me how they compare and contrast. I'd like to get an idea of what sort of learning curve I've got ahead of me.
Thanks,
Geoff
...
I wonder what are the main challenges to porting those emulator engines.
Could there been any sucess without having to rewrite all the code? Any conversion tools available that can help?
...
I should clarify that I am looking for a client-side solution.
Alternatively, is there a C# compiler written in managed code?
...
It seems with the built in friendly routing library in .NET MVC, it would allow us to do something like this.
In case it's not obvious what I want to with the built in stuff in .NET MVC, I want to a url starting with www to be automatically redirected to a non-www url using the MVC framework.
...