惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - 风的影

微服务 口试常见题 SQL 大数据查询如何进行优化? 事件和委托的区别 虚方法(virtual)和抽象方法(abstract)的和接口(interface)的区别 高并发的秒杀 C#算法 口试C#概念 口试Linq题 口试大数据及大并发问题 笔试题多线程 笔试代码考查 SQL笔试基础 口试基础 笔试基础知识 Asp.net项目从Vs2003转换到Vs2005的常见问题大全及解决方法 烦人的网页iframe去除 经典sql注入教程 自己写的后台静态权限验证类
C# 相当于ASP里Eval中的计算公式的方法(超简单的方法)
风的影 · 2007-08-02 · via 博客园 - 风的影
         

近日要把ASP程序改为ASP.NET(C#),原来的用了一个EVAL计算运费公式,换到C#里没有直接的相应功能

例:替换完重量后公式为((10-0.5)/0.5*55+210)/7.5*0.55,想得出结果

找了一上午,有说自己按运算符号优先级写个类计算,有说用CodeDom,还有说用堆栈Stack算法......

找到最后在一个不起眼的回复中找到下面方法,经测试可以使用

        DataTable dtl = new DataTable();
        string aa = dtl.Compute("((10-0.5)/0.5*55+210)/7.5*0.55","")).ToString(".##");

这应该算是最简单的实现方法了吧^_^