language-features

C# method call with parameter name and colon

不问归期 提交于 2019-11-27 02:03:29
问题 I've begun to notice at times when I'm making method calls in C# that the names of the parameters for the method I'm calling will show up in the intellisense list appended with a colon, and that I can then format the method call thusly: MethodCall(parameter1:value1, parameter2:value2); Is this a new language feature? It reminds me of the way you can call stored procedures in SQL and specify parameter names like so: spDoSomeStuff @param1 = 1, @param2 = 'other param' Is this a similar feature?

Are strings created with + concatenation stored in the string pool?

大兔子大兔子 提交于 2019-11-27 01:58:04
问题 For instance String s = "Hello" + " World"; I know there are two strings in the pool "Hello" and "World" but, does: "Hello World" go into the string pool? If so, what about? String s2 = new String("Hola") + new String(" Mundo"); How many strings are there in the pool in each case? 回答1: Yes, if a String is formed by concatenating two String literals it will also be interned. From the JLS: Thus, the test program consisting of the compilation unit (§7.3): package testPackage; class Test { public

Why do enums have computed properties but not stored properties in Swift?

可紊 提交于 2019-11-27 01:46:46
问题 I am new to Swift and just came across this in the documentation: Computed properties are provided by classes, structures, and enumerations. Stored properties are provided only by classes and structures. Why is that? Do associated values for enum work like stored properties? It seems like they had stored properties initially - Why no stored type properties for classes in swift? 回答1: enum s do have stored type properties - i.e., static properties. They don't have stored instance properties. I

Should I Use self Keyword (Properties) In The Implementation?

自作多情 提交于 2019-11-27 01:40:24
问题 I believe I understand properties for the most part. My question is, if I have a property for an instance variable, and I am setting or retrieving it from within a method in my implementation file, should I use self.myProperty or just myProperty ? I know either one works, but I have seen mixed conventions, sometimes code accesses the variable directly and other times through the property. Is there a technical reason for doing this? Is it just convention/personal preference? And I'm not

Will a future version of .NET support tuples in C#?

泪湿孤枕 提交于 2019-11-27 00:16:30
.Net 3.5 doesn't support tuples. Too bad, But not sure whether the future version of .net will support tuples or not? I've just read this article from the MSDN Magazine: Building Tuple Here are excerpts: The upcoming 4.0 release of Microsoft .NET Framework introduces a new type called System.Tuple. System.Tuple is a fixed-size collection of heterogeneously typed data. Like an array, a tuple has a fixed size that can't be changed once it has been created. Unlike an array, each element in a tuple may be a different type, and a tuple is able to guarantee strong typing for each element. There is

DateTime.Now vs. DateTime.UtcNow

老子叫甜甜 提交于 2019-11-26 23:21:14
I've been wondering what exactly are the principles of how the two properties work. I know the second one is universal and basically doesn't deal with time zones, but can someone explain in detail how they work and which one should be used in what scenario? Blair Conrad DateTime.UtcNow tells you the date and time as it would be in Coordinated Universal Time, which is also called the Greenwich Mean Time time zone - basically like it would be if you were in London England, but not during the summer. DateTime.Now gives the date and time as it would appear to someone in your current locale. I'd

Is there any Scala feature that allows you to call a method whose name is stored in a string?

妖精的绣舞 提交于 2019-11-26 22:46:13
问题 Assuming you have a string containing the name of a method, an object that supports that method and some arguments, is there some language feature that allows you to call that dynamically? Kind of like Ruby's send parameter. 回答1: You can do this with reflection in Java: class A { def cat(s1: String, s2: String) = s1 + " " + s2 } val a = new A val hi = "Hello" val all = "World" val method = a.getClass.getMethod("cat",hi.getClass,all.getClass) method.invoke(a,hi,all) And if you want it to be

Python type() or __class__, == or is

痞子三分冷 提交于 2019-11-26 22:41:00
问题 I want to test whether an object is an instance of a class, and only this class (no subclasses). I could do it either with: obj.__class__ == Foo obj.__class__ is Foo type(obj) == Foo type(obj) is Foo Are there reasons to choose one over another? (performance differences, pitfalls, etc) In other words: a) is there any practical difference between using __class__ and type(x) ? b) are class objects always safe for comparison using is ? Update: Thanks all for the feedback. I'm still puzzled by

Is the order of fields in a javascript object predictable when looping through them?

↘锁芯ラ 提交于 2019-11-26 22:03:05
问题 In php, if you have the following code: $map = array( "first" => 1, "second" => 2 ); $map["third"] = 3; foreach($map as $key => $value) { // code } You know the entries will be listed in the order they have been added to the array. Now, can I assume the same rule applies to the Javascript equivalent below? map = { "first": 1, "second": 2 }; map["third"] = 3; for (key in map) { // code } This is a duplicate of: Elements order - for (… in …) loop in javascript 回答1: Most browsers will loop

What are the differences between VB.NET and previous versions of VB? [closed]

被刻印的时光 ゝ 提交于 2019-11-26 22:02:54
问题 I'm reasonably familiar with the various forms of VB that existed prior to .NET (VB6, VBA, VBScript...), but have yet to delve into The Sweet New Flavor that is VB.NET. So I would very much appreciate it if someone would provide a quick summary of the major differences in the language brought about by VB.NET. 回答1: Assuming when you say vb you mean vb 6. Pretty big. The original visual basic does not use the .net runtime environment, and although they have similar names, they are pretty much