C#控制台程序生成exe
控制台程序在C#中默认生成dll,运行方式:
- 进入dll目录,输入start donet xxx.dll
- 添加代码
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
1
2
3
4
5
6
7
8
9
10
11
12
13
14<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RootNamespace>hello_C</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>2</WarningLevel>
</PropertyGroup>
</Project>
C#图形应用
创建项目选择WPF应用程序,出现设计窗口和逻辑窗口,分别为xaml文件与xaml.cs文件
xaml(Extensible Application Markup Language,可扩展应用程序标记语言)
C#语法
关键字如下
1 | abstract do in protected true as double int public try base else interface readonly typeof bool enum internal ref uint break event is return ulong byte explicit lock sbyte unchecked case extern long sealed unsafe catch false namespace short ushort char finally new sizeof using checked fixed null stackalloc virtual class float object static void const for operator string volatile continue foreach out struct while decimal goto override switch default if params this delegate implicit private throw |
标识符如下
1 | dynamic join set from let value get orderby var group partial where into select yield |
命名建议
驼峰命名
变量
decimal 货币值 比double有更高的精度和更小的范围 128位
赋值
未在声明时赋值的变量在C#中不可使用