C#学习第二步——认识语法结构

今天是我们学习C#的第二天,我们将要了解到C#的语法结构,快进来康康吧
摘要由CSDN通过智能技术生成

昨天在我们安装完IDE后,给出了这样的一段尝试代码:

Console.WriteLine("你好,请输入你的名字:");
			string str=Console.ReadLine();
			Console.WriteLine("你好"+str+",欢迎来到C#的世界");
			Console.ReadKey();
		

那有些同学就很好奇,这些代码外面的是什么呢?

 上面这些绿色的东西叫做注释,这些东西不会被编译和执行,就是来告诉你这行代码是干啥的,前期你可能会觉得,这些东西好像并没有什么用,但是如果我给出下面这段代码呢:

注:下面这两段代码转载自:C#实现关机的两种方法-ONE'S 博客1、使用shutdown关机命令来实现。 using System.Diagnostics; int time = 3600; //单位为:秒 Process.Start('c:/windows/system32/shutdown.exe', '-s -t '+time); ShutDown用法及参数(XP) 用法: shutdown [-i | -l | -s | -r | -a] [-f] [-m computernicon-default.png?t=M3C8https://www.liulei.com.cn/2254.html

using System;
using System.Runtime.InteropServices;
class shoutdown{
  [StructLayout(LayoutKind.Sequential, Pack=1)]
  internal struct TokPriv1Luid
  {
  public int Count;
  public long Luid;
  public int Attr;
  }
  [DllImport("kernel32.dll", ExactSpelling=true) ]
  internal static extern IntPtr GetCurrentProcess();
  [DllImport("advapi32.dll", ExactSpelling=true, SetLastError=true) ]
  internal static extern bool OpenProcess
  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值