如何用星号隐藏日期时间? [英] How do I hide the datetime with an asterisk?
问题描述
大家好。
我有一个加密和解密各种信息的功能,如姓名,地址等。我在Windows窗体上有一个按钮,如果你点击它,它会或者向您显示信息,或者用*隐藏它。
所以这里是我遇到问题的地方。对于名字文本框,我有这个:
firstName.Text = String.IsNullorEmpty(name.Column1)
? String.Empty
:**********+ name.Column1
以上代码将填充带有名字的文本框,当单击该按钮时,它将使用星号隐藏名称,反之亦然。但是,我有一个蒙面的texbox,它接收日期
Date.Text =(cardExpDate == null ||!cardExpDate。 Column1.HasValue)
? String.Empty
:Convert.ToDateTime(cardExpDate.Column1)。年== 1900
? String.Empty
:Convert.ToDateTime(cardExpDate.Column1).ToString(MM+****)
然而,它不是显示年份应该是*,而是空白。是否有某种我不知道的逃避角色?如何让它显示星号而不是空白?它只是显示,例如,如果月份是十月:10 /而不是10 / ****
任何建议都会得到很好的赞赏。
Hello all.
I have a function that encrypts and decrypts various information such as name, address, etc. I have a button on the windows form and if you click it, it will either show you the information, or, hide it with an "*"
So here is where I am having issues. For the first name textbox, I have this:
firstName.Text = String.IsNullorEmpty(name.Column1)
? String.Empty
: "**********" + name.Column1
The above code will populate the textbox with the first name and when the button is clicked, it will hide the name with asterisks and vice versa. However, I have a masked texbox that takes in the date
Date.Text = (cardExpDate == null || !cardExpDate.Column1.HasValue)
? String.Empty
: Convert.ToDateTime(cardExpDate.Column1).Year == 1900
? String.Empty
: Convert.ToDateTime(cardExpDate.Column1).ToString("MM" + "****")
however, instead of displaying a "*" where the year is supposed to be, it's just blank. Is there some sort of escape character that I don't know about? How do I make it show the asterisks instead of being blank? it just displays, for example, if the month is October: "10/ " instead of "10/****"
any suggestions would be grately appreciated.
推荐答案
代码Convert.ToDateTime(cardExpDate.Column1).ToString(MM+****)
。
将此更改为Convert.ToDateTime(cardExpDate.Column1).ToString(MM)+*** *
并尝试。
这篇关于如何用星号隐藏日期时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!