tagged [c#-3.0]

Stop Looping C#?

Stop Looping C#? How to stop my Loop if the value is already existing? here's my code in C#... ``` foreach (ArrayList item in ArrData) { HCSProvider.NewProviderResult oResult; oResult = oHCSProvid...

30 Mar at 05:48

Changing element value in List<T>.ForEach ForEach method

Changing element value in List.ForEach ForEach method I have the following code: I would expect that all elements in the list are now "WW" but they are still the original value. How come? What do I ha...

21 Jul at 18:7

How to find the periodicity in data?

How to find the periodicity in data? I have a dataset (an array) and I need to find the periodicity in it. How should I proceed? Somebody said I can use FFT but I am not sure how will it give me the p...

18 Dec at 20:26

Initializer syntax: new ViewDataDictionary { { "Name", "Value" } }

Initializer syntax: new ViewDataDictionary { { "Name", "Value" } } I was searching for a way to pass ViewDataDictionary to a partial view in ASP.NET MVC that I came to this syntax: I'm a bit confused ...

4 Sep at 07:45

LINQ to SQL entity and data-context classes: business object encapsulation

LINQ to SQL entity and data-context classes: business object encapsulation What are your favorite ways to encapsulate LINQ to SQL entity classes and data-context classes into business objects? What ha...

21 Oct at 23:28

Conversion double array to byte array

Conversion double array to byte array How do I convert a `double[]` array to a `byte[]` array and vice versa?

5 Aug at 07:45

Convert Date to "dd-MMM-yyyy" format c#

Convert Date to "dd-MMM-yyyy" format c# Guys i am unable to convert datetime to "dd-MMM-yyyy" format. My code is given below: I need to convert it as "20-Mar-2013". Please help me. Thanks.

21 Mar at 12:0

Remove all commas from a string in C# 3

Remove all commas from a string in C# 3 i have a string type variable like `a="a,b,c,d";`I want to remove all commas and get new value for a like `abcd`.I tried `a.Replace(",","")` but it is not worki...

1 Nov at 14:24

Declaration of Anonymous types List

Declaration of Anonymous types List Is there any way to declare a list object of anonymous type. I mean This is because I need to create a collection at runtime.

26 Jun at 14:17

C# adding a character in a string

C# adding a character in a string I know I can append to a string but I want to be able to add a specific character after every 5 characters within the string from this string alpha = abcdefghijklmnop...

Generate datetime format for XML

Generate datetime format for XML I'm trying to generate timestamp for cXML as shown below. Is there any function in C# which I can use to format date time to: 2011-06-09T16:37:17+16:37 e.g.

11 Jun at 04:55

Java RuntimeException equivalent in C#?

Java RuntimeException equivalent in C#? Does C# have the equivalent of Java's [java.lang.RuntimeException](http://download.oracle.com/javase/1.5.0/docs/api/java/lang/RuntimeException.html)? (I.E. an ...

Favorite way to create an new IEnumerable<T> sequence from a single value?

Favorite way to create an new IEnumerable sequence from a single value? I usually create a sequence from a single value using array syntax, like this: Or using a new List. I'd like to hear if anyone h...

19 Jun at 19:52

In C#, how can I know the file type from a byte[]?

In C#, how can I know the file type from a byte[]? I have a byte array filled from a file uploaded. But, in another part of the code, I need to know this file type uploaded from the byte[] so I can re...

Can we retrieve the method body from .dll file?

Can we retrieve the method body from .dll file? I have the requirement to retrieve the method body from a .dll file in C#. I'm using `System.Reflection` to retrieve the method names, parameters and pr...

27 Aug at 11:55

LINQ - selecting second item in IEnumerable

LINQ - selecting second item in IEnumerable I have `string[] pkgratio= "1:2:6".Split(':');` I want to select the middle value and have come up with this. Is this a correct way to select the second val...

13 Sep at 14:8

Generic List<T> as parameter on method

Generic List as parameter on method How can I use a `List` as a parameter on a method, I try this syntax : I got compilation error: > The type or namespace name 'T' could not be found (are you missing...

2 Jan at 11:58

Using Linq to Select properties of class to return IEnumerable<T>

Using Linq to Select properties of class to return IEnumerable If I have a `SortedList` and I want to return a new `IEnumerable` of properties from that class how do I do that? I have tried `SortedLis...

31 Jan at 12:38

Getting all types that implement an interface

Getting all types that implement an interface Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations? This is what I ...

Can I specify a meaningful name for an anonymous class in C#?

Can I specify a meaningful name for an anonymous class in C#? We all know that when we create an anonymous class like this: ...at run time it will be of type: Is there any way to specify a meaningful ...

18 Jul at 03:14

Using Linq find first object in list sorting by property A, then property B

Using Linq find first object in list sorting by property A, then property B I have an unordered list of Points (`List`) and I want to find the first Point in the list when ordering by X and then Y. NO...

24 Sep at 01:54

How to iterate through Dictionary and change values?

How to iterate through Dictionary and change values? I get an error: "Property or indexer 'System.Collections.Generic.KeyValuePair.Value' cannot be assigned to -- it is read only." How can I iterate t...

11 Aug at 09:27

how to override set in C# of automatic properties

how to override set in C# of automatic properties I want to use auto-implemented properties, but at the same time I want to call a method every time the property is changed. Does the previous code mak...

BindingList and LINQ?

BindingList and LINQ? I am new with Linq and I would like to sort some data that are in the BindingList. Once I did my Linq query, I need to use back the BindingList collection to bind my data. This c...

4 May at 13:20

How to split string into a dictionary

How to split string into a dictionary I have this string and am splitting it with Instead of that, how could I split the result into a `Dictionary`? The resulting dictionary should look like: ``` Key

5 Dec at 13:35