|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding | |
altering strings in C#
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | ||||||||||||
|
WaterCooler
|
I am writing an ASP.Net web-page for class and want to make it so that I can have the page after the user enters a credit card number display only the last 4 digits. I know in C++ it was something like:
Code:
CCNumber.substr(11,15) into a credit card number of: 3456. I would then be able to just put a string of ** in front of it. so long story short. what is the C# (or asp.net) equivalent of the .substr()?
__________________
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty. __________________
|
||||||||||||
|
|
|
|
#2 (permalink) | |||||||||||||
|
PC Gamer
|
That's odd... I was under the impression that .Substr() worked in C#. You could always try removing unwanted characters using .Remove()
__________________
|
|||||||||||||
|
|
|
|
|
#3 (permalink) | ||||||||||||
|
WaterCooler
|
hmm . . . maybe it does . . i should have double checked. . . I know its not in auto complete.
__________________
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty. __________________
|
||||||||||||
|
|
|
|
#4 (permalink) | ||||||||||||
|
WaterCooler
|
OMG. . . im an IDIOT . . mod feel free to close thread or ban me for being ignorant
![]() (misspelled the friggin variable)
__________________
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty. __________________
|
||||||||||||
|
|
|
|
#5 (permalink) | |||||||||||||
|
PC Gamer
|
happens to the best of us
__________________![]()
|
|||||||||||||
|
|
|
|
|
#6 (permalink) | ||||||||||||
|
WaterCooler
|
Still having the problem . . . when I try to alter the credit card string to only diplay the last 4 Digits using the following code I get an error. . . . any suggestions?
![]()
__________________
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty. __________________
Last edited by DanNEBTD : 02-15-08 at 11:33 PM. |
||||||||||||
|
|
|
|
#7 (permalink) | ||||||||||||
|
Programmer
|
the substring function is used like this:
string.SubString(int starting index, int length of substring) Since you are trying to get the last 4 digits, you would need to use substring(12, 4) - you are trying to get a 15 character substring that is located afer position 12, which is obviously not there, hence the out of bounds error.
__________________
"If there is a god, I hope he has a good excuse" Woody Allen
|
||||||||||||
|
|
|
|
|
#8 (permalink) | |||||||||||||
|
WaterCooler
|
Quote:
__________________
XPS M1330: T7500, 4GB, 13.3" LED WXGA, 128 8400 GS, 120GB 5400RPM, 802.11 AGN, 9 cell, Fingerprint, Ultimate x64, 4 Year Accidental Damage/lojack/warranty. __________________
|
|||||||||||||
|
|
|
|
#9 (permalink) | ||||||||||||
|
Programmer
|
Good stuff, glad to help out
__________________
"If there is a god, I hope he has a good excuse" Woody Allen
|
||||||||||||
|
|
|
|
|
#10 (permalink) | |||||||||||||
|
FLAC Attack
|
I thought you were talking about tuning a guitar...
__________________
|
|||||||||||||
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|