C#3.0提案 [英] C# 3.0 Proposals

查看:60
本文介绍了C#3.0提案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在哪里说明或反对某些C#3.0提案?


它们列在这里:

http:// download.microsoft.com/downlo...cification.doc


首先,我无法相信他们正试图通过
将C#转换为VB
使其成为非类型安全的语言。关于我的意思的一个例子,请阅读这个

来自文档的摘录:


" 26.1隐式输入的局部变量

In一个隐式类型的局部变量声明,声明的本地

变量的类型是从用于初始化变量的表达式中推断的。当局部变量声明指定var作为类型并且

没有名为var的类型在范围内时,声明是隐式类型的本地

变量声明。例如:


var i = 5;

var s =" Hello";

var d = 1.0;

var numbers = new int [] {1,2,3};

var orders = new Dictionary< int,Order>();"


我不知道你们这些人,但这只是闻起来像VB的变种

类型。 NASTY !!


-

-Demetri

Where can I go to state my views for or against some of the C# 3.0 proposals?

They are listed here:

http://download.microsoft.com/downlo...cification.doc

For one thing, I can not believe they are trying to convert C# to VB by
making it a non-type safe language. For an example of what I mean read this
excerpt from the doc:

"26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local
variable being declared is inferred from the expression used to initialize
the variable. When a local variable declaration specifies var as the type and
no type named var is in scope, the declaration is an implicitly typed local
variable declaration. For example:

var i = 5;
var s = "Hello";
var d = 1.0;
var numbers = new int[] {1, 2, 3};
var orders = new Dictionary<int,Order>();"

I don''t know about you guys, but that just smells too much like VB''s variant
type. NASTY!!

--
-Demetri

推荐答案

Demetri,


实际上,它与vb'的变体类型完全不同。例如,你可以

不这样做:


var stringVariable =" hello there" ;;

var numberVariable = 0 ;


//此行抛出编译错误。

numberVariable = stringVariable;


如你所指出在您复制和粘贴的部分中,它是一个

^隐式^类型的局部变量。这并不意味着它不强大

键入,它只是意味着它没有明确输入,如下所示:


string stringVariable =" ;你好那里;

int numberVariable = 0;


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Demetri" <德***** @ discussions.microsoft.com>在留言中写道

新闻:3C ********************************** @ microsof t.com ...
Demetri,

In reality, it is nothing like vb''s variant type. For example, you can
not do this:

var stringVariable = "hello there";
var numberVariable = 0;

// This line throws a compiler error.
numberVariable = stringVariable;

As you pointed out in the section that you copied and pasted, it is an
^implicitly^ typed local variable. This doesn''t mean that it is not strong
typed, it just means that it is not explicitly typed, like so:

string stringVariable = "hello there";
int numberVariable = 0;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
我可以在哪里提出或反对某些C#3.0提案的意见?

它们列在这里:

http://download.microsoft.com/downlo...cification.doc

首先,我无法相信他们正在尝试转换C#通过
使它成为一种非类型安全的语言。关于我的意思的一个例子,请阅读
这个
摘自文档:

26.1隐式类型的局部变量
在隐式类型的局部变量声明中,声明的局部变量的类型是从用于初始化变量的表达式推断出来的。当局部变量声明指定var作为类型
并且
没有名为var的类型在范围内时,声明是隐式类型的
局部变量声明。例如:

var i = 5;
var s =" Hello" ;;
var d = 1.0;
var numbers = new int [] {1 ,2,3};
var orders = new Dictionary< int,Order>();"

我不知道你们这些人,但那闻起来太像了VB'的
变体
类型。 NASTY !!

-Demetri
Where can I go to state my views for or against some of the C# 3.0
proposals?

They are listed here:

http://download.microsoft.com/downlo...cification.doc

For one thing, I can not believe they are trying to convert C# to VB by
making it a non-type safe language. For an example of what I mean read
this
excerpt from the doc:

"26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local
variable being declared is inferred from the expression used to initialize
the variable. When a local variable declaration specifies var as the type
and
no type named var is in scope, the declaration is an implicitly typed
local
variable declaration. For example:

var i = 5;
var s = "Hello";
var d = 1.0;
var numbers = new int[] {1, 2, 3};
var orders = new Dictionary<int,Order>();"

I don''t know about you guys, but that just smells too much like VB''s
variant
type. NASTY!!

--
-Demetri





" Demetri" <德***** @ discussions.microsoft.com>在留言中写道

新闻:3C ********************************** @ microsof t.com ...

"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
我可以在哪里提出或反对某些C#3.0提案的意见?

它们列在这里:

http://download.microsoft.com/downlo...cification.doc

首先,我无法相信他们正在尝试转换C#通过
使它成为一种非类型安全的语言。关于我的意思的一个例子,请阅读
这个
摘自文档:

26.1隐式类型的局部变量
在隐式类型的局部变量声明中,声明的局部变量的类型是从用于初始化变量的表达式推断出来的。当局部变量声明指定var作为类型
并且
没有名为var的类型在范围内时,声明是隐式类型的
局部变量声明。例如:

var i = 5;
var s =" Hello" ;;
var d = 1.0;
var numbers = new int [] {1 ,2,3};
var orders = new Dictionary< int,Order>();"

我不知道你们这些人,但那闻起来太像了VB'的
变体
类型。 NASTY !!

-Demetri
Where can I go to state my views for or against some of the C# 3.0
proposals?

They are listed here:

http://download.microsoft.com/downlo...cification.doc

For one thing, I can not believe they are trying to convert C# to VB by
making it a non-type safe language. For an example of what I mean read
this
excerpt from the doc:

"26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local
variable being declared is inferred from the expression used to initialize
the variable. When a local variable declaration specifies var as the type
and
no type named var is in scope, the declaration is an implicitly typed
local
variable declaration. For example:

var i = 5;
var s = "Hello";
var d = 1.0;
var numbers = new int[] {1, 2, 3};
var orders = new Dictionary<int,Order>();"

I don''t know about you guys, but that just smells too much like VB''s
variant
type. NASTY!!

--
-Demetri




我看到许多开发人员的这种误解。它是* NOT *无类型

变量(变体)。那些是表面上的打字。例如:


var i = 5;


这将i创建为整数并为其指定整数5。如果你以后再次决定将字符串或其他非整数数据分配给它,那么你会得到一个类型例外的




var i = 5;

i =" test" ;; < - 导致异常被抛出,因为你不能
将一个字符串分配给一个整数。


如果你进一步阅读有关该语言的内容综合查询的东西,你应该看看var和var。关键字是LIQ正常运行所需的东西

正确:)


HTH,

Mythran



I see this mis-conception by a lot of developers. It is *NOT* an untyped
variable (variant). Those are, in face, typed. For example:

var i = 5;

This creates i as an integer and assigns the integer 5 to it. If you later
decide to assign a string, or other non-integral data to it, then you would
get a type exception.

var i = 5;
i = "test"; <-- results in an exception being thrown because you can''t
assign a string to an integer.

If you read further about the language integrated query stuff, you should
see that the "var" keyword is something that is needed for LIQ to function
properly :)

HTH,
Mythran


那么使用对象类型装箱有什么问题。我假设这是

隐含的打字是否允许在设计时分配一个未知的类型




Isn''t var x = 1;与对象x = 1基本相同; ?


在两种情况下,如果我想在x上添加另一个数字,那么我必须在

之前知道我所添加的是int类型,对吗?


你可能会说,你可能不知道你要添加的是一个int,但是

我认为你需要要知道你可以在数学上添加




所以我不会在这个var(隐式)输入东西上出售。我当然希望它的

不是解决方法。安抚LINQ。构建一种语言来沟通

考虑到一套技术是我估计的一个糟糕的计划。


-

-Demetri

Nicholas Paldino [.NET / C#MVP]"写道:
So then what is wrong with boxing using the object type. I''m assuming this
"implicit" typing is there to allow one to assign a type that is not known
during design time?

Isn''t var x = 1; essentially the same as object x = 1; ?

In BOTH cases if I want to add another number to x then I must know before
hand that what i''m adding is of type int, correct?

You may argue, well you may not know that what you''re adding is an int, but
I argue that you will need to know somewhat in order to know that you CAN add
the to mathematically.

So i''m not sold on this var (implicit) typing thing. I certainly hope its
not a "workaround" to appease LINQ. Constructing a language to communicate
with one set of technolgies in mind is a bad plan in my estimation.

--
-Demetri
"Nicholas Paldino [.NET/C# MVP]" wrote:
Demetri,

实际上,它与vb'的变体类型完全不同。例如,你可以不这样做:

var stringVariable =" hello there";
var numberVariable = 0;

//这个line抛出编译器错误。
numberVariable = stringVariable;

正如您在复制和粘贴的部分中指出的那样,它是一个隐式^类型的局部变量。这并不意味着它不是很强类型,它只是意味着它没有明确输入,如下所示:

string stringVariable =" hello there" ;;
int numberVariable = 0;

希望这会有所帮助。

-
- Nicholas Paldino [.NET / C#MVP]
- mv*@spam.guard.caspershouse.com

Demetri <德***** @ discussions.microsoft.com>在消息中写道
新闻:3C ********************************** @ microsof t.com。 ..
Demetri,

In reality, it is nothing like vb''s variant type. For example, you can
not do this:

var stringVariable = "hello there";
var numberVariable = 0;

// This line throws a compiler error.
numberVariable = stringVariable;

As you pointed out in the section that you copied and pasted, it is an
^implicitly^ typed local variable. This doesn''t mean that it is not strong
typed, it just means that it is not explicitly typed, like so:

string stringVariable = "hello there";
int numberVariable = 0;

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
我可以在哪里提出或反对某些C#3.0提案的意见?

它们列在这里:

http://download.microsoft.com/downlo...cification.doc

首先,我无法相信他们正试图通过<将C#转换为VB使它成为一种非类型安全的语言。关于我的意思的一个例子,请阅读
这个
摘自文档:

26.1隐式类型的局部变量
在隐式类型的局部变量声明中,声明的局部变量的类型是从用于初始化变量的表达式推断出来的。当局部变量声明指定var作为类型
并且
没有名为var的类型在范围内时,声明是隐式类型的
局部变量声明。例如:

var i = 5;
var s =" Hello" ;;
var d = 1.0;
var numbers = new int [] {1 ,2,3};
var orders = new Dictionary< int,Order>();"

我不知道你们这些人,但那闻起来太像了VB'的
变体
类型。 NASTY !!

-
-Demetri
Where can I go to state my views for or against some of the C# 3.0
proposals?

They are listed here:

http://download.microsoft.com/downlo...cification.doc

For one thing, I can not believe they are trying to convert C# to VB by
making it a non-type safe language. For an example of what I mean read
this
excerpt from the doc:

"26.1 Implicitly typed local variables
In an implicitly typed local variable declaration, the type of the local
variable being declared is inferred from the expression used to initialize
the variable. When a local variable declaration specifies var as the type
and
no type named var is in scope, the declaration is an implicitly typed
local
variable declaration. For example:

var i = 5;
var s = "Hello";
var d = 1.0;
var numbers = new int[] {1, 2, 3};
var orders = new Dictionary<int,Order>();"

I don''t know about you guys, but that just smells too much like VB''s
variant
type. NASTY!!

--
-Demetri




这篇关于C#3.0提案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆