C#之資料類型學習

來源:互聯網
上載者:User

標籤:thread   取值   gen   linq   threading   NPU   nta   技術分享   inf   

C#有以下幾種資料類型:

資料類型案例以及取值範圍:

介面:

選擇int時:

選中long時:

選中float時:

選中double時:

選中decimal時:

選中string時:

選中char時:

選中Bool時:

原始碼如下:

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 SecondWpf
{
     /// <summary>
     /// MainWindow.xaml 的互動邏輯
     /// </summary>
     public partial class MainWindow : Window
     {
         public MainWindow()
         {
             InitializeComponent();
         }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
          
         }

        private void Button_Click(object sender, RoutedEventArgs e)
         {
             Close();//當Quit鍵被按下以後,退出系統
         }

        private void ListBoxItem_Selected(object sender, RoutedEventArgs e)
         {
             int variable,IntMax,IntMin;
             variable = 42;
             IntMax = (int)Math.Pow(2, 32)-1;
             IntMin = (int)Math.Pow(-2, 32);
             Value.Text = variable.ToString() ;
             Down.Text = IntMin.ToString();
             Uper.Text = IntMax.ToString();
         }

        private void List1_Selected(object sender, RoutedEventArgs e)
         {
             long LongMax, LongMin,variable;
             variable = 42L;
      
             LongMax = (long)Math.Pow(2, 63) - 1;
             LongMin = (long)Math.Pow(-2, 63);
             Value.Text = variable.ToString();
             Down.Text = LongMax.ToString();
             Uper.Text = LongMin.ToString();
         }

        private void List2_Selected(object sender, RoutedEventArgs e)
         {
             float variable;
             string FloatMax, FloatMin;
             variable = 0.42f;
             FloatMax = "(+-)1.5*10^45";
             FloatMin = "(+-)3.4 * 10 ^ 45";
             Value.Text = variable.ToString();
             Down.Text = FloatMax;
             Uper.Text = FloatMin;
         }

        private void List3_Selected(object sender, RoutedEventArgs e)
         {
             double variable;
             string DoubleMax;
             string DoubleMin;
             variable = 0.43;
             DoubleMax = "+-5.0*10^-324";
             DoubleMin = "+-1.7*10^308";
             Value.Text = variable.ToString();
             Down.Text = DoubleMax;
             Uper.Text = DoubleMin;

        }

        private void List4_Selected(object sender, RoutedEventArgs e)
         {
             decimal coin;
             string DecimalMax, DecimalMin;
             coin = 0.42M;
             DecimalMax ="+-1.0*10^-28";
             DecimalMin = "+-7.9*10^28"; 
             Value.Text = coin.ToString();
             Down.Text = DecimalMax.ToString();
             Uper.Text = DecimalMin.ToString();
         }

        private void List5_Selected(object sender, RoutedEventArgs e)
         {
             string vest;
             vest = "你好!";
             Value.Text = vest;
             Down.Text = "null";
             Uper.Text = "null";
         }

        private void List6_Selected(object sender, RoutedEventArgs e)
         {
             char grill;
             int CharMax, CharMin;
             grill = ‘x‘;
             CharMax = (int)Math.Pow(2, 16) - 1;
             CharMin = 0;
             Value.Text = grill.ToString();
             Down.Text = CharMin.ToString();
             Uper.Text = CharMax.ToString();
         }

        private void List7_Selected(object sender, RoutedEventArgs e)
         {
             bool teeth;
             teeth = false;
             Value.Text = teeth.ToString();
             Down.Text ="Ture";
             Uper.Text = "Flase";
         }
     }
}

C#之資料類型學習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.