如何在C#中声明变量 [英] how to declare variable in c#

查看:62
本文介绍了如何在C#中声明变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中声明变量?在Java脚本和C#中声明的区别是什么?

how to declare variable in c# what is difference in declaration in java script and c#

推荐答案

C#
string myString;
// or
string myString = "value";



Javascript:



Javascript:

var myString;
//or
var MyString="value";



在C#中,您必须指定类型,但是在Javascript中,分配值的行为定义了变量的类型.您也可以根据需要明确指定类型.



In C# you must specify the type, but in Javascript, the act of assigning a value defines a variable''s type. You can also specify the type explicitly if you want.



请访问以下链接,

C#3.0概述 [局部变量声明 [
Please visit following links,

Overview of C# 3.0[^]

Local variable declarations[^]

Hope it will help you :)


这篇关于如何在C#中声明变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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