Re: String formats
From: Joakim Karlsson (jkarlsson_at_NOSPAMjkarlsson.com)
Date: 01/19/05
- Next message: JSM: "Re: Writing extended ascii characters to text file."
- Previous message: MuZZy: "Re: Problems using PInvoke to read a PhysicalDrive"
- In reply to: Jac: "String formats"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 21:03:55 +0100
Try this:
using System;
class App
{
static void Main(string[] args)
{
int n1 = 234;
int n2 = 5645;
string s1 = n1.ToString("00000");
string s2 = n2.ToString("00000");
int mod = int.Parse(s1+s2) % 97;
string res = String.Format("+++{0}/{1}{2}/{3}{4}+++",
s1.Substring(0,3), s1.Substring(3,2), s2.Substring(0,2),
s2.Substring(2,3), mod.ToString("00"));
Console.WriteLine(res);
}
}
Regards,
Joakim
Jac wrote:
> Hey,
>
> Can someone help me to find a short and effective way to do the follow.
>
> I have
> Number1 as integer = 234
> Number2 as integer = 5645
>
> I want to create a string as follows (it is an obligatoire format for the
> banks):
> +++123/4567/89012+++
>
> My example :
> Number1 I want to present in a 5 char string, but left aligned with 0
> Number 2 the same
>
> as follows : 0023405645
> from that int I have to calculate the MODULO 97 = 30
>
> Now the string must be in following format
> +++002/3405/64530+++
>
> I looked in regex but don't find a good way to do it.
>
> Thanks for help.
> jac
>
- Next message: JSM: "Re: Writing extended ascii characters to text file."
- Previous message: MuZZy: "Re: Problems using PInvoke to read a PhysicalDrive"
- In reply to: Jac: "String formats"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|