聚合问答列表
4 浏览

delegate keyword vs. lambda notation

Once it is compiled, is there a difference between: delegate { x = 0; } and () => { x = 0 } ?

c#,.net,delegates,lambda,anonymous-methods 2017-11-30
3 浏览

Where to learn about VS debugger 'magic names'

If you've ever used Reflector, you probably noticed that the C# compiler generates types, methods, fields, and local variables, that deserve 'special' display by the debugger. For instance, local vari...

c#,compiler-construction,debugging 2017-11-30
4 浏览

Transactions in .net

What are the best practices to do transactions in C# .Net 2.0. What are the classes that should be used? What are the pitfalls to look out for etc. All that commit and rollback stuff. I'm just startin...

c#,.net,transactions 2017-11-30
AD 友情赞助
3 浏览

Difference between ref and out parameters in .NET

What is the difference between ref and out parameters in .NET? What are the situations where one can be more useful than the other? What would be a code snippet where one can be used and another can't...

c#,.net 2017-11-30
5 浏览

Can I automatically increment the file build version when using Visual Studio?

I was just wondering how I could automatically increment the build (and version?) of my files using Visual Studio (2005). If I look up the properties of say C:\Windows\notepad.exe, the Version tab g...

c#,asp.net,visual-studio,version-control,assemblyinfo 2017-11-30
3 浏览

How is Math.Pow() implemented in .NET Framework?

I was looking for an efficient approach for calculating ab (say a = 2 and b = 50). To start things up, I decided to take a look at the implementation of Math.Pow() function. But in .NET Reflector, all...

c#,.net,pow 2017-11-30
AD 友情赞助
3 浏览

Path.Combine for URLs?

Path.Combine is handy, but is there a similar function in the .NET framework for URLs? I'm looking for syntax like this: Url.Combine("http://MyUrl.com/", "/Images/Image.jpg") which would return: ...

c#,.net,asp.net,url,path 2017-11-30
4 浏览

How can I ensure that a division of integers is always rounded up?

I want to ensure that a division of integers is always rounded up if necessary. Is there a better way than this? There is a lot of casting going on. :-) (int)Math.Ceiling((double)myInt1 / myInt2)

c#,math 2017-11-30
3 浏览

Can you loop through all enum values? [duplicate]

This question already has an answer here: How to enumerate an enum? 14 answers public enum Foos { A, B, C } Is there a way to loop through the possible values of Foos? Basically?...

c#,.net,enums,language-features 2017-11-30
AD 友情赞助
3 浏览

How to call functions in a main view model from other view models?

My program is composed of a TreeView and two contentPresenters at ground level. The mainWindow, TreeView, and each contentPresenter all have their own viewModels. I would like to call a function in t...

c#,wpf,mvvm,viewmodel 2017-11-30
3 浏览

Conditional operator assignment with Nullable types?

EmployeeNumber = string.IsNullOrEmpty(employeeNumberTextBox.Text) ? null : Convert.ToInt32(employeeNumberTextBox.Text), I often find myself wanting to do things like this (EmployeeNumber is ...

c#,conditional-operator,nullable 2017-11-30
4 浏览

EF codefirst : Should I initialize navigation properties?

I had seen some books(e.g programming entity framework code first Julia Lerman) define their domain classes (POCO) with no initialization of the navigation properties like: public class User { pu...

c#,entity-framework,ef-code-first,domain-driven-design,navigation-properties 2017-11-30
AD 友情赞助
4 浏览

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression

I'm migrating some stuff from one mysql server to a sql server but i can't figure out how to make this code work: using (var context = new Context()) { ... foreach (var item in collection) ...

c#,mysql,sql,linq 2017-11-30
2 浏览

Write Array to Excel Range

I'm currently trying to write data from an array of objects to a range in Excel using the following code, where objData is just an array of strings: private object m = System.Type.Missing; object[] o...

c#,excel,interop 2017-11-30
3 浏览

How can I divide two integers to get a double?

How do I divide two integers to get a double?

c#,math 2017-11-30
4 浏览

Simulating Key Press c#

I want to simulate F5 key press in my c# program, When IE is open I want to be able refresh my website automatically,and I dont know where to start. thanks, Dani.

c# 2017-11-30
5 浏览

Dynamic WHERE clause in LINQ

What is the best way to assemble a dynamic WHERE clause to a LINQ statement? I have several dozen checkboxes on a form and am passing them back as: Dictionary<string, List<string>> (Dict...

c#,linq,dynamic,where-clause 2017-11-29
6 浏览

Distinct by property of class with LINQ

I have a collection: List<Car> cars = new List<Car>(); Cars are uniquely identified by their property CarCode. I have three cars in the collection, and two with identical CarCodes. Ho...

c#,linq,distinct 2017-11-29
6 浏览

What is the difference between a regular string and a verbatim string?

I have a trial version of Resharper and it always suggests that I switch regular strings to verbatim strings. What is the difference?

c#,resharper 2017-11-29
4 浏览

How to embed a text file in a .NET assembly?

I would like to embed a text file in an assembly so that I can load the text without having to read it from disk, and so that everything I need is contained within the exe. (So that it's more portable...

c#,.net,embedded-resource 2017-11-29
AD 友情赞助