TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dave
NA
2
0
Converting integers to bits/bytes
Feb 26 2008 3:46 AM
Hello there. I am not a sessoned programmer and actually have very little experiance in c#. I have undertaken a project and one of the functions of my porject is to turn string numbers, into bits or bit vectors I beleive they are called. Like I said I am not a brilliant programmer and have had much help with this before. I have currently been changing the strings to ints first. But now I realised that bit vectors are more relevant. The code I am using is: private void button4_Click(object sender,System.EventArgs e) { string text =txtBoxBefore.Text; string expression =@"\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"; text =Regex.Replace(text, expression, new MatchEvaluator(IpToUInt)); txtBoxAfter.Text=(text); } public static string IpToUInt (Match m) { string[] temp =m.Value.Split('.'); uint[] octets = new uint[4]; for (int i = 0; i < 4; i++) { octets[i] =uint.Parse(temp[i]); } return (octets[0] +(octets[1] << 8) + (octets[2] << 16) +(octets[3] << 24)).ToString(); } public static string IpFromUInt2 (uint ui) { uint[] octets = new uint[4]; octets[3] = ui >> 24; uint remainder = ui -(octets[3] << 24); octets[2] = remainder >> 16; remainder -= octets[2] << 16; octets[1] = remainder >> 8; remainder -= octets[1] << 8; octets[0] = remainder; string[] temp = new string[4]; for (int i = 0; i < 4; i++) { temp[i] = octets[i].ToString(); } return String.Join(".", temp); } Any help would be great. Thanks And im also guessing that seeing that ive tried to edit this three times now it doesnt allow for spaccing between sentances.
Reply
Answers (
1
)
Database connectivity in Client Server architechture
Check if Server, DB and SP exists