Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 01-30-08   #1 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,321

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 270
Hardware Reviews: 8
Trader Rating: 8
Default altering strings in C#

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)
that could make a credit card number of 1234 5678 9012 3456
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()?
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
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.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 01-30-08   #2 (permalink)
PC Gamer
 
exitmusic's Avatar
 
intel nvidia

Join Date: Nov 2007
Location: Ottawa, Ontario
Posts: 87

Rep: 4 exitmusic Unknown
Unique Rep: 4
Trader Rating: 0
Default

That's odd... I was under the impression that .Substr() worked in C#. You could always try removing unwanted characters using .Remove()
__________________
System: black & blue
CPU
E7200 @ 3GHz
Motherboard
DFI Blood Iron
Memory
2x2048MB Mushkin XP PC2-8000
Graphics Card
eVGA 8800GTS 512
Hard Drive
2x150GB WD Raptor SATA, 250GB WD Caviar SATAII
Sound Card
Creative SB X-Fi XtremeMusic
Power Supply
Enermax Liberty 500W
Case
Gigabyte 3D Aurora Aluminum (Black)
CPU cooling
Stock (for now)
GPU cooling
Stock
OS
Vista Ultimate x64, Ubuntu 8.04
Monitor
Dell 2407WFP
exitmusic is online now   Reply With Quote
Old 01-30-08   #3 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,321

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 270
Hardware Reviews: 8
Trader Rating: 8
Default

hmm . . . maybe it does . . i should have double checked. . . I know its not in auto complete.
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
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.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 01-30-08   #4 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,321

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 270
Hardware Reviews: 8
Trader Rating: 8
Default

OMG. . . im an IDIOT . . mod feel free to close thread or ban me for being ignorant

(misspelled the friggin variable)
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
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.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 01-30-08   #5 (permalink)
PC Gamer
 
exitmusic's Avatar
 
intel nvidia

Join Date: Nov 2007
Location: Ottawa, Ontario
Posts: 87

Rep: 4 exitmusic Unknown
Unique Rep: 4
Trader Rating: 0
Default

happens to the best of us
__________________
System: black & blue
CPU
E7200 @ 3GHz
Motherboard
DFI Blood Iron
Memory
2x2048MB Mushkin XP PC2-8000
Graphics Card
eVGA 8800GTS 512
Hard Drive
2x150GB WD Raptor SATA, 250GB WD Caviar SATAII
Sound Card
Creative SB X-Fi XtremeMusic
Power Supply
Enermax Liberty 500W
Case
Gigabyte 3D Aurora Aluminum (Black)
CPU cooling
Stock (for now)
GPU cooling
Stock
OS
Vista Ultimate x64, Ubuntu 8.04
Monitor
Dell 2407WFP
exitmusic is online now   Reply With Quote
Old 02-15-08   #6 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,321

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 270
Hardware Reviews: 8
Trader Rating: 8
Default

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?

Attached Thumbnails
altering-strings-c-ccerror.jpg  
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
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.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia

Last edited by DanNEBTD : 02-15-08 at 11:33 PM.
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 02-16-08   #7 (permalink)
Programmer
 
stupid's Avatar
 
amd nvidia

Join Date: Jan 2006
Location: Fahaheel, Kuwait
Posts: 1,219

Rep: 143 stupid is acknowledged by manystupid is acknowledged by many
Unique Rep: 112
FAQs Submitted: 1
Trader Rating: 4
Default

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

System: Minazo
CPU
Opteron 1210
Motherboard
Biostar TForce 550 SE
Memory
2x1GB G.Skill DDR2 800
Graphics Card
eVGA 8800GT
Hard Drive
500GB 16MB Buf Samsung
Power Supply
Corsair HX520W Modular
Case
CoolerMaster Centurion 5
CPU cooling
CoolerMaster GeminII & Scythe SFF21Ds
GPU cooling
Accelero S1 & Scythe SFF21D
OS
XP Pro SP2
Monitor
Dual monitors: 22" & 19" Widescreens
stupid is offline   Reply With Quote
Old 02-16-08   #8 (permalink)
WaterCooler
 
DanNEBTD's Avatar
 
amd nvidia

Join Date: Mar 2006
Location: Boca Raton, FL
Posts: 2,321

Rep: 120 DanNEBTD is acknowledged by manyDanNEBTD is acknowledged by many
Unique Rep: 103
Folding Team Rank: 270
Hardware Reviews: 8
Trader Rating: 8
Default

Quote:
Originally Posted by stupid View Post
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.
hehe, never actually had to use that in C++ so I never read up on it. Thanks for the help.
__________________
Quote:
Originally Posted by GuardianOdin View Post
Overkill doesn't exist on OCN. It's what we do.
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.
__________________

System: The 1K CFM Machine
CPU
Opty 170 ccb1e 0609fpaw
Motherboard
A8N32-SLI
Memory
2 gigs Gskill PC4000
Graphics Card
EVGA 7950X2
Hard Drive
4x 36gig Raptors raid 0, 1x 200gig storage
Sound Card
XtremeMusic w/Z5500
Power Supply
PC&P Silencer 750 Quad
Case
Mozart Tx
CPU cooling
Stinger V6, quadrad
OS
Vista Home Premium x86
Monitor
32" Syntax Olevia
DanNEBTD is offline I fold for Overclock.net DanNEBTD's Gallery   Reply With Quote
Old 02-16-08   #9 (permalink)
Programmer
 
stupid's Avatar
 
amd nvidia

Join Date: Jan 2006
Location: Fahaheel, Kuwait
Posts: 1,219

Rep: 143 stupid is acknowledged by manystupid is acknowledged by many
Unique Rep: 112
FAQs Submitted: 1
Trader Rating: 4
Default

Good stuff, glad to help out
__________________
"If there is a god, I hope he has a good excuse"
Woody Allen

System: Minazo
CPU
Opteron 1210
Motherboard
Biostar TForce 550 SE
Memory
2x1GB G.Skill DDR2 800
Graphics Card
eVGA 8800GT
Hard Drive
500GB 16MB Buf Samsung
Power Supply
Corsair HX520W Modular
Case
CoolerMaster Centurion 5
CPU cooling
CoolerMaster GeminII & Scythe SFF21Ds
GPU cooling
Accelero S1 & Scythe SFF21D
OS
XP Pro SP2
Monitor
Dual monitors: 22" & 19" Widescreens
stupid is offline   Reply With Quote
Old 02-16-08   #10 (permalink)
FLAC Attack
 
pow3rtr1p's Avatar
 
intel ati

Join Date: May 2006
Location: The Keywork
Posts: 5,854
Blog Entries: 3

Rep: 414 pow3rtr1p is a proven memberpow3rtr1p is a proven memberpow3rtr1p is a proven memberpow3rtr1p is a proven memberpow3rtr1p is a proven member
Unique Rep: 307
FAQs Submitted: 3
Folding Team Rank: 354
Team Name: Ninjas with Lasers V2.0
Trader Rating: 11
Default

I thought you were talking about tuning a guitar...
__________________
System: Soberclock.net
CPU
E8400 3.9 GHz @ 1.344V
Motherboard
DFI LP Dark P35
Memory
2x1GB Team D9GMH
Graphics Card
Sapphire x1950XTX
Hard Drive
250 GB WD Caviar
Sound Card
b-Enspirer + ATH-A900s
Power Supply
Silverstone DA750 (60A 12V)
Case
Cooler Master Stacker 832
CPU cooling
Xigmatek HDT-S1283 w/ Yate Loon @ 40C Load
GPU cooling
UV Red Stock w/ AS5 @ 52C Load
OS
Vista Home Premium 64-Bit
Monitor
Samsung 204-B 1600 x 1200
pow3rtr1p is offline I fold for Overclock.net Overclocked Account pow3rtr1p's Gallery   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 12:12 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.19763 seconds with 10 queries