确定哪个函数基于十进制的长度来调用 [英] Determine which function to call based on length of decimal

查看:160
本文介绍了确定哪个函数基于十进制的长度来调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中,我有一个情况我有一个TextBox控件两个可能的号码

In C#, I have a situation where I have two possible numbers in a textbox control.

中的数字可以是:

A).XXXX

二).XX

我怎样写,说,一个条件:如果文本框有四个小数位,然后调用这个函数,否则,如果文本框有2位小数,然后再调用这个函数。

How do I write a condition that says, "If the textbox has 4 decimal places, then call this function, otherwise, if the textbox has 2 decimal places, then call this function."

似乎很容易,但我不知道该如何评价小数。

Seems easy, but I don't know how to evaluate the decimal places.

谢谢了!

推荐答案

您可以使用正则表达式

new Regex(@"\.\d{2}$").IsMatch(input.Value)

这篇关于确定哪个函数基于十进制的长度来调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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