C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to do Randomgeneration of string


Posted Date: 05 May 2008    Resource Type: Articles    Category: .NET Framework

Posted By: Redhat       Member Level: Silver
Rating:     Points: 10



The following code sample shows how to do randomgeneration of string

public string GetRandomString(int length)
{
int intZero = 0, intNine = 0, intA = 0, intZ = 0, intCount = 0, intRandomNumber = 0;
string strRandomString;
Random rRandom = new Random(System.DateTime.Now.Millisecond);
intZero = '0';
intNine = '9';
intA = 'A';
intZ = 'Z';
strRandomString = "";
while (intCount < length)
{
intRandomNumber = rRandom.Next(intZero, intZ);
if (((intRandomNumber >= intZero) && (intRandomNumber <= intNine) && (intRandomNumber <= intNine) || (intRandomNumber >= intA) && (intRandomNumber <= intZ)))
{
strRandomString = strRandomString + (char)intRandomNumber;
intCount = intCount + 1;
}
}
return strRandomString;
}




Responses

Author: Sebastian    13 Jun 2008Member Level: Gold   Points : 1
This is very informative. Thanks for sharing the details.


Author: antogladwin    17 Jun 2008Member Level: Silver   Points : 1
hi,
very usefull information .thank u..keep it..continue ur posting



Author: Gaurav Agrawal    18 Jun 2008Member Level: Silver   Points : 1
Hi,

Your article is very useful.
keep posting your article.
It is very useful for .Net Elite team members.
Thanks
Gaurav Agrawal.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Multicast delegates: an example
Previous Resource: Responsibilities of CLR (Common Language Runtime)
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

web conferencing services

Contact Us    Privacy Policy    Terms Of Use