Advertisement
nguyenvanquan7826

Tạo ra một lớp lưu trữ giá trị nguyên

Feb 18th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. /*Tạo   ra   một  lớp   lưu   trữ   giá   trị   nguyên   tên   myNumber.   Tạo  thuộc   tính   cho  thành
  2. viên này. Khisố đượclưutrữthì nhân cho 100. Và khi số được truycập thìchia cho 100.*/
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace MyNumber
  11. {
  12.     class My
  13.     {
  14.         public static void input()
  15.         {
  16.             number = float.Parse(Console.ReadLine());
  17.         }
  18.         public float Num
  19.         {
  20.             get
  21.             {
  22.                 return number / 100;
  23.             }
  24.             set
  25.             {
  26.                 number = value;
  27.                 number = number * 100;
  28.             }
  29.         }
  30.        
  31.         public private float number;
  32.     }
  33.     class Program
  34.     {
  35.         static void Main(string[] args)
  36.         {
  37.             My.input();
  38.             float a=My.Num;
  39.             Console.WriteLine("Out: {0}",a);
  40.             Console.ReadLine();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement