이전 기사에서는 일부 데이터 유형에 대해 사전적으로 이해했지만 포괄적이지 않았으므로 진지하고 현실적인 정신으로 데이터 유형을 다시 정리하겠습니다.
값형의 정수형 :
C언어 수업을 들을 때 선생님께서도 이런 표를 보고 쓰라고 하신 기억이 납니다. 잘 살펴보지 않고 이걸 기억하는 것도 소용없다고 생각했는데, 다음 코드를 실행해보니 선생님의 좋은 의도를 알 수 있었습니다:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Example { class Program { static void Main(string[] args) { short x = 32766; x++; Console.WriteLine(x); x++; Console.WriteLine(x); Console.ReadKey(); } } }
결과는 의외였습니다. 🎜>
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Example { class Program { static void Main(string[] args) { int x; Console.WriteLine("姓名:"); String name = Console.ReadLine(); Console.WriteLine("电话号码: "); x = int.Parse(Console.ReadLine()); //类型转换 Console.WriteLine("你的名字叫:" + name + "\t" + "你的电话是:{0}", x); } } }
int i =9; String Str = ”HC666“ Console.WriteLine(Str+i);
HC6669
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Example { class Program { static void Main(string[] args) { String 姓名="HC666"; int 年龄=16; double 身高=1.70; Console.WriteLine("姓名:{0},年龄:{1},身高:{2}", 姓名, 年龄, 身高); } } }