从今天开始学习 C#

第一次写C#,发现C#语法有很多奇怪的地方,括号一多头都看晕了。

ContractedBlock.gif ExpandedBlockStart.gif 我的第一个C#代码
None.gifpublic partial class _Default : System.Web.UI.Page 
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
protected void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif      
InBlock.gif         Response.Write(
"====================循环语句1=======================<p>");
InBlock.gif            
int i = 0;
InBlock.gif        
for (i = 0; i < 10; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Response.Write(i 
+ "<br>");
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        Response.Write(
"==================循环语句2=========================<p>");
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
string[] arr1 =dot.gif"str1""str2""str3" };
InBlock.gif        
InBlock.gif            
int t=0;
InBlock.gif        
InBlock.gif            
for (t = 0; t<arr1.Length; t++)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Response.Write(arr1[t] 
+ "<br>");
InBlock.gif
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        Response.Write(
"=====================条件语句1======================<p>");
InBlock.gif
InBlock.gif       
InBlock.gif        
string str3 = "xm";
InBlock.gif        
string str4 = "fj";
InBlock.gif        Response.Write(
"str3=xm" + "   " + "str4=fj");
InBlock.gif        
if (str3 == str4)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Response.Write(
"A");
ExpandedSubBlockEnd.gif        }

InBlock.gif            
else
InBlock.gif            
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            str3 
= str4;
ExpandedSubBlockEnd.gif        }

InBlock.gif        Response.Write(str3);
InBlock.gif
InBlock.gif
InBlock.gif        Response.Write(
"<p>=====================条件语句2======================<p>");
InBlock.gif
InBlock.gif
InBlock.gif        
int caseSwitch = 1;
InBlock.gif        
switch (caseSwitch)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
case 1:
InBlock.gif                Response.Write(
"Case 1");
InBlock.gif                
break;
InBlock.gif            
case 2:
InBlock.gif                Response.Write(
"Case 2");
InBlock.gif                
break;
InBlock.gif            
default:
InBlock.gif                Response.Write(
"Default case");
InBlock.gif                
break;
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值