1、console
namespace MyNamespace
{
class MyClass
{
static void Main(string[] args)
{
Console.WriteLine("Hello,World!");
}
}
}
2、WPF
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 WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void buttonSayHello_Click(object sender, RoutedEventArgs e)
{
textShowHello.Text = "Hello,World!";
}
}
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="#FF1DC1D6" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<TextBox x:Name="textShowHello" HorizontalAlignment="Left" Margin="10,9,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="783" RenderTransformOrigin="0.5,0.5" Height="33">
<TextBox.CaretBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black"/>
<GradientStop Color="#FFE91F1F"/>
</LinearGradientBrush>
</TextBox.CaretBrush>
<TextBox.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-0.11"/>
<TranslateTransform/>
</TransformGroup>
</TextBox.RenderTransform>
</TextBox>
<Button x:Name="buttonSayHello" Content="click me" HorizontalAlignment="Left" Margin="0,62,0,0" VerticalAlignment="Top" Width="790" Height="31" Click="buttonSayHello_Click"/>
</Grid>
</Window>
3、windows forms
namespace WinFormsApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void buttonSayHello_Click(object sender, EventArgs e)
{
textBoxSayHello.Text = "Hello,World!";
}
}
}
4、ASP.NET Web Forms
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="WebApplication2._default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<h1>Hello,World!</h1>
</body>
</html>
5、ASP.NET MVC(Model-View-Controller)
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
<h2>Hello,World!</h2>
}