using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("你好,欢迎来到C#3.0的世界");
Console.Read();
}
}
}
1.倒数第二行大括号前,“等待用户输入任意键”是啥意思?
2.Read() ,ReadLine() 相当与scanf();
ReadKey()只是为了运行暂停;
WriteLine(),Write()相当于printf();
对不?
3.using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HelloWindows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "Hello,C#3.0";//设置textBox1的text属性
}
}
}
错误 当前上下文中不存在名称“textBox1” C:\Users\Administrator\AppData\Local\Temporary Projects\HelloWindows\Form1.cs 26 13 HelloWindows
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloCSharp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("你好,欢迎来到C#3.0的世界");
Console.Read();
}
}
}
1.倒数第二行大括号前,“等待用户输入任意键”是啥意思?
2.Read() ,ReadLine() 相当与scanf();
ReadKey()只是为了运行暂停;
WriteLine(),Write()相当于printf();
对不?
3.using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HelloWindows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "Hello,C#3.0";//设置textBox1的text属性
}
}
}
错误 当前上下文中不存在名称“textBox1” C:\Users\Administrator\AppData\Local\Temporary Projects\HelloWindows\Form1.cs 26 13 HelloWindows
没看到这句话,不知道是注释还是什么让你迷惑了2.Read() ,ReadLine() 相当与scanf();
还是有那么些区别的,首先C#不会给你转型,你得自己显示的转换类型,如果读入的不是字符串的话,其次 read 与scanf 有些像,忽略开始的空白符,遇到后来的空白符结束,ReadLine 和gets有些像,遇到回车结束ReadKey()只是为了运行暂停;
有些人这么用,不过这句就是读入一个字符,不用输回车什么的,见过控制台有个提示,让你输Y/N吧,就是这个作用,当然也可以让程序暂停,等待用户随便输入后继续WriteLine(),Write()相当于printf();
这两个区别和上面的类似,输出语句嘛