字符串格式和计算 [英] string format and calcualtions

查看:58
本文介绍了字符串格式和计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用字符串格式,


获取具有相同结构的输入Nm Nf Ny(n是一个数字,例如:  2m 3f 2y)


我想做一些计算(总是相同):  Nm * 6 + Nf * 7 + Ny / 2


是否可以使用字符串格式?


谢谢

解决方案

您可以尝试自定义格式:


https://docs.microsoft.com/en-us/dotnet/api/system.string.format ?view = netframework-4.7.2#example-a-custom-formatting-operation






can I using string format,

get input with same structure Nm Nf Ny (n is a number for example : 2m 3f 2y)

and I want to do some calculation (always be the same one) : Nm*6+ Nf*7+ Ny/2

is it possible with string format?

Thanks

解决方案

You can try custom formatting:

https://docs.microsoft.com/en-us/dotnet/api/system.string.format?view=netframework-4.7.2#example-a-custom-formatting-operation



这篇关于字符串格式和计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆