第一种方法:

string na="1000.53";

int a=int.Parse(na.Substring(0,na.IndexOf('.')));//返回值a=1000

第二种方法:

string na = "100.6";
Console.WriteLine(Convert.ToInt32 (Math.Truncate(Convert.ToDouble(na))));

第三种方法:

return  Convert.ToInt32("100.6".split(".")[0]);

【原】C# decimal字符串转成整数的更多相关文章

  1. 【LeetCode-面试算法经典-Java实现】【008-String to Integer (atoi) (字符串转成整数)】

    [008-String to Integer (atoi) (字符串转成整数)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Implement atoi to co ...

  2. 17.把字符串转换成整数[atoi]

    [题目] 把字符串转换成整数,需要考虑字符串有效性. [代码]  C++ Code  123456789101112131415161718192021222324252627282930313233 ...

  3. Java将ip字符串转换成整数的代码

    下面代码是关于Java将ip字符串转换成整数的代码,希望对各位有较大用途. public class IpUtil { public static int Ip2Int(String strIp){ ...

  4. 【Java】 剑指offer(67) 把字符串转换成整数

      本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集   题目 请你写一个函数StrToInt,实现把字符串转换成整数这个功能 ...

  5. 《剑指offer》第六十七题(把字符串转换成整数)

    // 面试题67:把字符串转换成整数 // 题目:请你写一个函数StrToInt,实现把字符串转换成整数这个功能.当然,不 // 能使用atoi或者其他类似的库函数. #include <ios ...

  6. Python使用函数实现把字符串转换成整数

    需求:假设Python没有提供内置函数int如果使用函数方式实现把一串字符串转换成整数例如把字符串‘12345‘转换成整数12345 思路 1,字符串也是序列可以使用map函数处理分割成一个列表 2, ...

  7. [Leetcode] String to integer atoi 字符串转换成整数

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  8. 算法练习-字符串转换成整数(实现atoi函数)

    练习问题来源 https://leetcode.com/problems/string-to-integer-atoi/ https://wizardforcel.gitbooks.io/the-ar ...

  9. 剑指Offer - 九度1508 - 把字符串转换成整数

    剑指Offer - 九度1508 - 把字符串转换成整数2014-02-06 23:46 题目描述: 将一个字符串转换成一个整数,要求不能使用字符串转换整数的库函数. 输入: 输入可能包含多个测试样例 ...

随机推荐

  1. linux 安装redis

    1:首先命令行下载安装包 wget http://download.redis.io/releases/redis-2.8.13.tar.gz 2:进行解压 tar xzf redis-2.8.13. ...

  2. ZOJ 1088 System Overload

    原题链接 题目大意:浙大的破网络容量有限,太多人同时使用BBS就会系统崩溃.为了保持系统正常工作,过载时就需要切断部分用户.规则是把玉泉所有的建筑从1到n编号,设定一个常数m.从1开始数,第m幢建筑的 ...

  3. Testing Round #8 A. IQ Test 水题

    题目链接:http://codeforces.com/problemset/problem/328/A 这道题目wa了一次,注意这句话: You should also print 42 if the ...

  4. c 函数及指针学习 6

    不完整声明 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 /* 方法一   */ struct tag_a{ ...

  5. leetcode 140. Word Break II ----- java

    Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each ...

  6. 第n小的质数

    总时间限制:  1000ms 内存限制:  65536kB 描述 输入一个正整数n,求第n小的质数. 输入 一个不超过10000的正整数n. 输出 第n小的质数. 样例输入 10 样例输出 29 代碼 ...

  7. C语言中强制数据类型转换(转)

    原文地址不详 字符型变量的值实质上是一个8位的整数值,因此取值范围一般是-128-127,char型变量也可以加修饰符unsigned,则unsigned char 型变量的取值范围是0-255(有些 ...

  8. Android项目——传感器的使用

    public class MainActivity extends Activity { // 定义 方向传感器 和 重力传感器 private TextView tvOrientation, tvA ...

  9. 论文阅读之:PRIORITIZED EXPERIENCE REPLAY

    PRIORITIZED EXPERIENCE REPLAY ICLR 2016 经验回放使得 online reinforcement learning agent 能够记住并且回放过去的经验.在先前 ...

  10. Linux comands

    https://www.mankier.com/8/vmstat http://docs.oracle.com/cd/E23824_01/html/821-1451/spmonitor-22.html ...