language-features

VB.NET equivalent of C# property shorthand?

╄→尐↘猪︶ㄣ 提交于 2019-11-26 12:57:21
问题 Is there a VB.NET equivalent to the C#: public string FirstName { get; set; } I know you can do Public Property name() As String Get Return _name.ToString End Get Set(ByVal value As String) _name = value End Set End Property But I can\'t seem to google up an answer on a Visual Basic shorthand. 回答1: There is no shorthand for Visual Studio 2008 or prior for VB.NET. In Visual Studio 2010 and beyond, you can use the following shorthand: public property FirstName as String This will be handled as

What are C macros useful for?

此生再无相见时 提交于 2019-11-26 12:50:52
问题 I have written a little bit of C , and I can read it well enough to get a general idea of what it is doing, but every time I have encountered a macro it has thrown me completely. I end up having to remember what the macro is and substitute it in my head as I read. The ones that I have encountered that were intuitive and easy to understand were always like little mini functions, so I always wondered why they weren\'t just functions. I can understand the need to define different build types for

When do I need to use Begin / End Blocks and the Go keyword in SQL Server?

这一生的挚爱 提交于 2019-11-26 12:36:27
问题 Can someone tell me when and where I need to use begin and end blocks in SQL Server? Also, what exactly does the Go keyword do? 回答1: GO is like the end of a script. You could have multiple CREATE TABLE statements, separated by GO. It's a way of isolating one part of the script from another, but submitting it all in one block. BEGIN and END are just like { and } in C/++/#, Java, etc. They bound a logical block of code. I tend to use BEGIN and END at the start and end of a stored procedure, but

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

给你一囗甜甜゛ 提交于 2019-11-26 12:21:46
问题 .Net 3.5 doesn\'t support tuples. Too bad, But not sure whether the future version of .net will support tuples or not? 回答1: 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

DateTime.Now vs. DateTime.UtcNow

随声附和 提交于 2019-11-26 12:19:58
问题 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? 回答1: 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.

Equivalent of Class Loaders in .NET

点点圈 提交于 2019-11-26 11:49:47
问题 Does anyone know if it possible to define the equivalent of a \"java custom class loader\" in .NET? To give a little background: I am in the process of developing a new programming language that targets the CLR, called \"Liberty\". One of the features of the language is its ability to define \"type constructors\", which are methods that are executed by the compiler at compile time and generate types as output. They are sort of a generalization of generics (the language does have normal

C# Null propagating operator / Conditional access expression & if blocks

痴心易碎 提交于 2019-11-26 11:36:05
问题 The Null propagating operator / Conditional access expression coming in c#-6.0 looks like quite a handy feature. But I\'m curious if it will help solve the problem of checking if a child member is not null and then calling a Boolean method on said child member inside an if block: public class Container<int>{ IEnumerable<int> Objects {get;set;} } public Container BuildContainer() { var c = new Container(); if (/* Some Random Condition */) c.Objects = new List<int>{1,2,4}; } public void Test()

What is the purpose of python&#39;s inner classes?

∥☆過路亽.° 提交于 2019-11-26 09:16:31
问题 Python\'s inner/nested classes confuse me. Is there something that can\'t be accomplished without them? If so, what is that thing? 回答1: Quoted from http://www.geekinterview.com/question_details/64739: Advantages of inner class: Logical grouping of classes : If a class is useful to only one other class then it is logical to embed it in that class and keep the two together. Nesting such "helper classes" makes their package more streamlined. Increased encapsulation : Consider two top-level

Why isn&#39;t the eigenclass equivalent to self.class, when it looks so similar?

吃可爱长大的小学妹 提交于 2019-11-26 07:54:38
问题 I\'ve missed the memo somewhere, and I hope you\'ll explain this to me. Why is the eigenclass of an object different from self.class ? class Foo def initialize(symbol) eigenclass = class << self self end eigenclass.class_eval do attr_accessor symbol end end end My train of logic that equates the eigenclass with class.self is rather simple: class << self is a way of declaring class methods, rather than instance methods. It\'s a shortcut to def Foo.bar . So within the reference to the class

Methods in Ruby: objects or not?

淺唱寂寞╮ 提交于 2019-11-26 06:29:23
问题 Inspired by this discussion, after some googling I wasn\'t able to find an answer to a pretty simple question regarding methods in Ruby: are methods objects or not? There are different opinions here and there, and I would really like to hear, let\'s say, an in-depth explanation. I\'m aware of Object#method method, which takes a method name and returns a Method instance, but, on the other hand, there\'s a similar thing you can do with blocks to make them into Proc instances, and blocks aren\'t