1 使用VS创建基本的程序
1.1 创建控制台应用程序
在VS中新建项目Visual C#的控制台应用即可,笔者所用的VS2017中的目录为:Visual C# / Windows 经典桌面 / 控制台应用(.NET Framework)。
一个超简短的控制台输出程序如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("This is the first ConsoleApp");
}
}
}
其他可以使用的Console类方法还有ReadLine(), Readkey()等等。
1.2 利用WPF(Windows Presentation Foundation)创建桌面应用程序
在笔者的VS2017中,创建新项目的目录为:Visual C# / Windows 经典桌面 / WPF应用(.NET Framework)
在.cs文件中写逻辑,在.xaml文件中设计界面控件。在设计界面时,工具箱(ToolBox)中有需要的控件。控件可以在XAML代码中精确地控制。
最简单的示例代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp2
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
//此处为点击Button的响

这篇博客主要介绍了从C++转学C#的快速入门,包括如何在VS中创建控制台和WPF应用,C#的新语法特性如数据类型、引用ref和输出参数out、参数数组以及委托delegate。同时讲解了C#的OOP概念,如类的修饰符、接口和类库的使用。
最低0.47元/天 解锁文章
10万+

被折叠的 条评论
为什么被折叠?



