首页 > 其他分享 >随便记点

随便记点

时间:2022-11-24 03:44:18浏览次数:40  
标签:30 记点 MaxValue MinValue 随便 short WriteLine sizeof

刚学

C#10.0

引用空间在解决方案里,单击打开代码编辑或查看。也可以右键解决方案-属性里编辑。

命名要规范,double类型不要拿来做==的对比,目前有个疑问。

C#的格式化字符串不太能理解,还有

Console.WriteLine(format:"{0,-10} {1,6:NO}",arg0:"Name",arg1:"Count");

Console.WriteLine("{0,-10} {1,6:NO}",  "Name",  "Count");

这俩差别在哪?

看完第二章了,练习2.3:

 

 自己写的:

using static System.Console;
string[] a = new[]{"sbyte","byte","short","ushort","int","uint","long","ulong","float","double","decimal"};
WriteLine("------------------------------------------------------------------------");
WriteLine("{0,-8}{1,-17}{2,17}{3,30}","Type","Byte(s) of memory","min","Max");
WriteLine("------------------------------------------------------------------------");
WriteLine($"{a[0],-8}{sizeof(sbyte),-4}{sbyte.MinValue,30}{sbyte.MaxValue,30}");
WriteLine($"{a[1],-8}{sizeof(byte),-4}{byte.MinValue, 30}{ byte.MaxValue,30}");
WriteLine($"{a[2],-8}{sizeof(short),-4}{short.MinValue,30}{short.MaxValue,30}");
WriteLine($"{a[3],-8}{sizeof(ushort),-4}{short.MinValue,30}{short.MaxValue,30}");
WriteLine($"{a[4],-8}{sizeof(int),-4}{int.MinValue,30}{int.MaxValue,30}");
WriteLine($"{a[5],-8}{sizeof(uint),-4}{uint.MinValue,30}{uint.MaxValue,30}");
WriteLine($"{a[6],-8}{sizeof(long),-4}{long.MinValue,30}{long.MaxValue,30}");
WriteLine($"{a[7],-8}{sizeof(ulong),-4}{ulong.MinValue,30}{ulong.MaxValue,30}");
WriteLine($"{a[8],-8}{sizeof(float),-4}{float.MinValue,30}{float.MaxValue,30}");
WriteLine($"{a[9],-8}{sizeof(double),-4}{double.MinValue,30}{double.MaxValue,30}");
WriteLine($"{a[10],-8}{sizeof(decimal),-4}{decimal.MinValue,30}{decimal.MaxValue,30}");
WriteLine("------------------------------------------------------------------------");

运行:

 

 

 

using static System.Console;

WriteLine("--------------------------------------------------------------------------");
WriteLine("Type    Byte(s) of memory               Min                            Max");
WriteLine("--------------------------------------------------------------------------");
WriteLine($"sbyte   {sizeof(sbyte),-4} {sbyte.MinValue,30} {sbyte.MaxValue,30}");
WriteLine($"byte    {sizeof(byte),-4} {byte.MinValue,30} {byte.MaxValue,30}");
WriteLine($"short   {sizeof(short),-4} {short.MinValue,30} {short.MaxValue,30}");
WriteLine($"ushort  {sizeof(ushort),-4} {ushort.MinValue,30} {ushort.MaxValue,30}");
WriteLine($"int     {sizeof(int),-4} {int.MinValue,30} {int.MaxValue,30}");
WriteLine($"uint    {sizeof(uint),-4} {uint.MinValue,30} {uint.MaxValue,30}");
WriteLine($"long    {sizeof(long),-4} {long.MinValue,30} {long.MaxValue,30}");
WriteLine($"ulong   {sizeof(ulong),-4} {ulong.MinValue,30} {ulong.MaxValue,30}");
WriteLine($"float   {sizeof(float),-4} {float.MinValue,30} {float.MaxValue,30}");
WriteLine($"double  {sizeof(double),-4} {double.MinValue,30} {double.MaxValue,30}");
WriteLine($"decimal {sizeof(decimal),-4} {decimal.MinValue,30} {decimal.MaxValue,30}");
WriteLine("--------------------------------------------------------------------------");

 

   看了眼mark的代码:
using static System.Console;

WriteLine("--------------------------------------------------------------------------");
WriteLine("Type    Byte(s) of memory               Min                            Max");
WriteLine("--------------------------------------------------------------------------");
WriteLine($"sbyte   {sizeof(sbyte),-4} {sbyte.MinValue,30} {sbyte.MaxValue,30}");
WriteLine($"byte    {sizeof(byte),-4} {byte.MinValue,30} {byte.MaxValue,30}");
WriteLine($"short   {sizeof(short),-4} {short.MinValue,30} {short.MaxValue,30}");
WriteLine($"ushort  {sizeof(ushort),-4} {ushort.MinValue,30} {ushort.MaxValue,30}");
WriteLine($"int     {sizeof(int),-4} {int.MinValue,30} {int.MaxValue,30}");
WriteLine($"uint    {sizeof(uint),-4} {uint.MinValue,30} {uint.MaxValue,30}");
WriteLine($"long    {sizeof(long),-4} {long.MinValue,30} {long.MaxValue,30}");
WriteLine($"ulong   {sizeof(ulong),-4} {ulong.MinValue,30} {ulong.MaxValue,30}");
WriteLine($"float   {sizeof(float),-4} {float.MinValue,30} {float.MaxValue,30}");
WriteLine($"double  {sizeof(double),-4} {double.MinValue,30} {double.MaxValue,30}");
WriteLine($"decimal {sizeof(decimal),-4} {decimal.MinValue,30} {decimal.MaxValue,30}");
WriteLine("--------------------------------------------------------------------------");

.....字符串能直接塞里面去啊,尬了

睡了睡了,今天就到这

标签:30,记点,MaxValue,MinValue,随便,short,WriteLine,sizeof
From: https://www.cnblogs.com/miea/p/16920698.html

相关文章

  • 百度地图添加大量标记点卡顿解决思路
    百度地图加载大量mark点的一种思路需求即能加载多个点,又能加载海量点,又能工具条件经常切换,在尝试了多种方式之后,用下面的方式满足了条件思路:先通过setTimeout分布加载......
  • Jmeter,请求头随便定义
    HTTPHeaderManager:Content-Type:application/json;charset=UTF-8Accept-Language:zh-CNAccept-Encoding:gzip,deflateAccept:application/json,text/plain,/User......
  • 随便写写
     在群里的发言被说成没过脑子不知悔改,说话也变的成为了一件需要小心翼翼的事,在顾客面前小心翼翼的讲话因为不理解这个人,以前在实习的时候,有一个顾客来买车,说了一些买了车......
  • BUUCTF [强网杯 2019]随便注 1
    1.拿到题目,先输入一个1'试一下是否存在注入点报错error1064:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMariaDBserverve......
  • 2022分享一款好用的喜马拉雅音频下载工具,想听啥随便下!
    最近有小伙伴留言,想要找一个跟喜马拉雅听书的软件,很牛的的那种。目前,听书的软件有很多,小编熟知的主要有喜马拉雅、懒人听书、咪咕听书、氧气听书、蜻蜓FM等等。喜马拉雅作......
  • 随便写一个promise
    functionmyPromise(fn){this.state='Pending'this.valuethis.resolve=function(){if(this.state!='Pending'){return......
  • 随便做做
    CF1188C:发现每个序列值不超过$\dfrac{\max(a[i])-\min(a[i])}{k-1}$。这样值域变得很小,那么答案表示可以是目标序列数量乘值。发现排序后,差值单调递增,过程可优化为\(......
  • vs 使用随便
    自从使用makefile、cmake后,再次感受到了vs带来的方便。对vs使用进行简单记录: 当你需要添加外部的头文件和库的时候,你只需要:1.把头文件的目录添加到"c/c++......
  • MBR转GPT分区(根分区不要随便转,重启后系统会挂)
    场景:MBR分区已经分了4四主分区,无法再扩容。解决思路:把MBR转换为GPT,再扩容。准备工具:gdisk1、df-h  #查看当前分区情况 2、MBR转GPT(gdisk)看一眼有没有gdisk命令,......
  • 【随便翻翻】Steam Deck现在(基本上)不通过预订就能购买到
    根据Valve的消息,你不再需要通过预订来购买这家公司于今年早些时候发售的掌上游戏机SteamDeck。每个型号现在都应该可以购买到。在撰写本文时(2022年10月7日),Valve预计所有......