c#基础02字符和字符串练习题

这篇博客介绍了C#中处理字符和字符串的基础练习,包括如何获取4位数的个位、十位、百位和千位。虽然没有用户输入部分的完整实现,但展示了如何通过数学运算来分解数字,并且展示了类型转换和字符串拼接的概念。
摘要由CSDN通过智能技术生成

namespace c_02zy
{
class Program
{
static void Main(string[] args)
{
// 1.由用户输入一个4位数的数字,分别求出该数字的个位、十位、百位、千位
//Console.WriteLine(“请输入一个4为数的数字”);
//string i = Console.ReadLine();
//4 Console.WriteLine(i % 10);
//2 Console.WriteLine(i / 100 % 10);
//1 Console.WriteLine(i / 1000 % 10);
//int a = 0;
//string b=null;
//if(a is int)
//{
// a = Convert.ToInt32(i);
// b = a % 10 + “个” + a / 10 % 10 + “十” + a / 100 % 10 + “百” + a / 1000 % 10+”千”;

        //}
        //Console.WriteLine(b);
        //Console.ReadKey();





        //2.定义一个变量记录硬盘的大小,如1GB,那么计算这个硬盘有多少MB。有多少KB。有多少Byte。(1024规则)
        //Console.WriteLine("请输入一个。。。GB");
        //string i = Console.ReadLine();
        //int c = 0;
        //int a=0;
        //int b=0;
        //int d=0;
        //if(c is int)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值