.net

DateTime.AddDays or new DateTime

I'm creating a list of a month's worth of dates. I'm wondering what will be more efficient List<DateTime> GetDates(DateTime StartDay) { List<DateTime> dates = new List<DateTime>(); int TotalDays=StartDay.AddMonths(1).AddDays(-1).Day; for (int i=1; i<TotalDays; i++) { dates.Add(new DateTime(StartDay.Year, StartDay.Month, i)); ...

Is “Code Access Security” of any real world use?

I am in the process of studying for the 70-536 .NET Framework - Application Development Foundation Exam, as I have been programming .net for many years, this should not be hard! However I am having to learn about “Code Access Security” (CAS), As I have never had a need to use or configure it, I was wondering if anyone else has found a ...

Proper way to have an endless worker thread?

I have an object that requires a lot of initialization (1-2 seconds on a beefy machine). Though once it is initialized it only takes about 20 miliseconds to do a typical "job" In order to prevent it from being re-initialized every time an app wants to use it (which could be 50 times a second or not at all for minutes in typical usage), ...

Rebranding Application Resources in .NET 2.0

I'm about to start writing a tool in .NET 2.0 (C#), and the tool needs to be re-brandable to be sold for use by other companies. We'll compile the tool in house, with other company's resources, so they don't get the source, just the generated output. Since the re-branding will use the same default language, how do you manage multiple r...

Is it possible to add an interface to a strongly typed DataSet in .NET?

I've got a bunch of strongly typed DataSet that each have two tables. One table is unique for each DataSet, but the second, "MetaData", has the same schema for each DataSet. At runtime, I determine which DataSet I want to use, and populate the data table in the appropriate way from a DB. I then want to populate the MetaData table. Th...

Are .NET resource files only for localization?

I've used .resx files in the past to store text files and other things - queries for example. It works great because I can say Resources.Queries.BlahQuery. (Yes, I know we should probably used stored procedures, but that's another story...) I'll never be doing any localization on these resources. Is this a bad idea? Am I misusing .NET ...

building method for LINQ query to strip chars from records

I need to strip the following chars from my records using LINQ to SQL query "\";:'.,=+!@#$%^&*(_)~{}[]\\|<>? aeiouAEIOU" I can do it with my linq query here from p in customers select new {customer_name = String.Concat(p.First_name.Replace("A","@"),p.Last_name.Replace("A","@")), address = p.Address.Replace("A","@") } but I know th...

Create single permutation with Linq in C#

I have a code: List<int> list = new List<int>(); for (int i = 1; i <= n; i++) list.Add(i); Can I create this List<int> in one line with Linq? ...

How to determine MAC Address of the actual physical network card -- not virtual network interfaces created by VPN's (.NET C#)

Background I'm trying to get obtain a unique identifier out of a computer and want to be able to reliably return the same MAC address each time. Trust me I have my reasons for using MAC address and have read many posts about alternate unique id methods (and yes i've considered if they don't have any network cards). Problem The prob...

Where can I find interesting .Net screencasts ? (F#, IronRuby, IronPython,...)

I'm looking for interesting screencasts targetting .Net (no podcasts) to extend what I already propose on my screencast aggregator at http://www.learnivore.com. Can you help me find the most interesting ones you'd be aware of ? Those I already know: http://www.dimecasts.net http://www.monotouch.info (.Net development on iPhone!) a se...

Missing features in WPF

I have been using WPF for a while now, and while I'm finding it excellent generally, I find it is still missing a number of features. I would like to use this question to compile a list of the most wanted WPF features, and hopefully provide some workarounds. Please only post one feature per reply so that people can vote. Maybe MS are li...

ICollection to String in a good format in C#

I have a List: List<int> list = new List<int> {1, 2, 3, 4, 5}; If want to get string presentation of my List. But code list.ToString() return "System.Collections.Generic.List'1[System.Int32]" I am looking for standard method like this: string str = list.Aggregate("[", (aggregate, value) => ...

How to show accelerators when context menu triggered from code

As I understand it, when the Windows "Hide underlined letters for keyboard navigation until I press the Alt key" checkbox is checked, when a context menu is shown via a right-click, the underlines should be hidden, but when it is shown via the Apps key or by Shift+F10, they should be shown. In C#, I have added a context menu to a third-p...

How to iterate through a list of an anonymous type

I have a list of Countries and i would like to separately get the name of the country and the CountryID. To be more understandable please visit this link where i have uploaded an image http://img251.imageshack.us/img251/8505/listx.jpg How is this possible with an anonymous type? I tried Countries[0]["Country"] but with no luck. ...

Xmlserializer not serializing base class members

I'm having this very odd issue while trying to serialize a class for logging using XmlSerializer. The code was generated by the wsdl.exe tool. The class that gets serialized as is declared as follows: [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.Debugger...

Inheriting From Sealed Classes

Lets say I have a Phone number my classes need to validate and keep track of and for the most part a phone number is just a string so in an attempt to be DRY one would just create a Phone class and inherit from string. Since I can't do that what is the next best approach? Adding a string as a private member and overloading the equal/= ...

how can i get the button's command argument?

Is it possible to get a button's command argument in javascript. I don't want to manipulate it, i just want to read it. If possible - how? ...

What is a LINQ provider?

What is a "LINQ provider," and what is its purpose? ...

How to obtain process of newly created IE8 window?

When using .NET's Process.Start to run IE8's iexplore.exe, and if you already have another IE8 window open, then the iexplore.exe process that you just started will immediately exit, and its child process will attach to the main IE8 process. The result of this is your Process object will be linked to the "invoker" process that has alread...

finger print reader and .net cf

I am looking for a finger print sdk that can run on .net compact frame work and can make use of the in built finger scanning hardware of pda's like hp ipaq etc .thanks ...