You searched for how does c# work. We found 81 results in 0.401 seconds.

how does this small c# code work

I joined a new team that automates using c# and selenium. I cant follow how this line works: driver.FindElement(Elements.OkLink).click() I know about why driver and...
Jon Skeet
people
quotationmark

Is LinkText a method. Yes. I thought methods are similar to functions. That's right. How is ClassName MethodName is used here. In the declaration? That just indicates what the method returns. So to pull this declaration... more

people

How does List<Struct>.Contains() work?

I have programed a very simple struct in C# (I'm using Visual Studio 2012 with .NET 4.5) public struct MyStruct { public Int32 X { get; set; } public Int32 Y { get; set;...
Jon Skeet
people
quotationmark

How does the .Contains() method perform the comparison? It uses the default equality comparer for the type, as documented: This method determines equality by using the default equality comparer So essentially, something like... more

people

How does reflection work on resource repositories

I want to understand how such a code works to retrieve the resource of the specified ThreadUI Culture? var value = resourceAssembly .GetType("Namespace.FooBar") ...
Jon Skeet
people
quotationmark

If you open up the generated C# file corresponding to that type, you'll see something like this: internal static string Hello { get { return ResourceManager.GetString("Hello", resourceCulture); } } Unless you specific... more

people

C# How does dll references work?

I'm developing a client application which connects with a web service, in order to do that I'm using the WebClient class and the JavaScriptSerializer class for parse the requested...
Jon Skeet
people
quotationmark

It should be fine so long as the machine you're copying it to has the full version of .NET - not just a client profile. You shouldn't need to copy anything - it should just be fine to pull it from the GAC. Just make sure you've got the... more

people

How does params work in c# (One method allegedly hiding another)

How does c# make params work. When you have code like static string Concat(int arg) { return arg.ToString(); } static string Concat(int arg, params string[] p) { ...
Jon Skeet
people
quotationmark

I think calling it "hiding" is misleading here, to be honest. Both methods are definitely created, but if you call: Concat(5); then for that invocation both methods are applicable (in the terminology of the C# spec section 7.5.3.1) but... more

people

How does inheritance of instance fields work in this particular code?

class A { int a = 2, b = 3; public void display() { int c = a + b; System.out.println(c); } } class B extends A { int a = 5, b = 6; } class...
Jon Skeet
people
quotationmark

why does the output comes 5,5? Because A.display() only knows about the fields A.a and A.b. Those are the only fields that any code in A knows about. It looks like you expect the declarations in B to "override" the existing field... more

people

How do extension methods work in C#?

I'm not entirely sure as to how to figure out if a method is an extension method or not. I read the following guidelines: The method has to be in a static class (for example...
Jon Skeet
people
quotationmark

I don't understand is how we know which class the method is extending. Is it the class that has this preceding it? Yes. It's always the first parameter of the method. You can't decorate any other parameter with this. (And it's the... more

people

Why default does not work with double parentheses?

Why this compiles: return default(T); but this does not: return default((T)); The full method is public static T PenultimateOrDefault<T>(this IEnumerable<T>...
Jon Skeet
people
quotationmark

Well, that's just not how the language is specified. It's important to understand that default is like typeof - they're operators1, not method calls. It's not like the name of the type is an argument - it's an operand, and the operand is... more

people

How does .NET framework low level APIs work?

One of the questions that i always faced was the implementation of .NET Framework class libraries. I know some of the methods original implementation: For example :...
Jon Skeet
people
quotationmark

Can you do exact same thing without using that method? Actually Nope. You absolutely can. Here's a really inefficient way of doing it - which doesn't consider overflow, invalid input or negative numbers, but demonstrates the general... more

people

How does parsing a c# date to be a javascript date even work with the ')'?

I know that to convert a C# date, like /Date(1430341152570)/ to a JavaScript date, it's the following: var part = "/Date(1430341152570)/".substr(6); // =>...
Jon Skeet
people
quotationmark

From the Mozilla documentation: If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. parseInt truncates... more

people