Showing posts with label .net fram work. Show all posts
Showing posts with label .net fram work. Show all posts

How to Extract Digits From a String in C#

How to Extract digits from a string in Csharp. String is a common data type which we use in our code but some time we have to perform some kind of function on string. It is a example of how you can extract numeric digits. Follow the following steps:
Requirement for the use of timer control is following.

- Operating System : Windows XP, Windows 7 , Vista
- Platform : .Net 2.0 or greater
- IDE : Visual Studio
- Language : Csharp

Now Follow the following steps :

- Create New Project on Visual Studio
- Select language C#
- Now Select the Console Application

Add this to your code at top :

-
using System.Text.RegularExpressions;

Use the Following Function :

public static string[] ExtractDigits(string data)
{
System.Text.RegularExpressions.MatchCollection matches
= System.Text.RegularExpressions.Regex.Matches(data,@"(\d+\.?\d*|\.\d+)");
string[] MatchList = new string[matches.Count];
int c = 0;
foreach (System.Text.RegularExpressions.Match match in matches)
{
MatchList[c] = match.ToString();
c++;
}
return MatchList;
}
Now you can use this function in many forms for example im using it for sum of digits :

static void Main(string[] args)
{
string st = "sfdsdfj3w4ew3434mnskjfns34wq34";
int sum = 0;
string[] arra = ExtractDigits(st);

for (int i = 0; i < arra.Length; i++) { Console.WriteLine(arra[i]); sum+= Convert.ToInt32(arra[i]); } Console.WriteLine("SUM is : "+sum.ToString()); Console.ReadLine(); }

How To Create A Log File

We start from the simple question that why we need to create a log file in our application. Simple is that log file keep record of all transaction of data or tells us about the action that we done in application. It help us to recover all previous data. I read many forum related to coding from where I get the question, is there any kind of built in function or .dll in C# that maintains log file. So answer to that question is that there is no such a function or .dll that handle this event. For this purpose I will suggest that y u not make your own program that help you to create a log file.

How To Create Hot Key in Windows Application With Csharp

This is my 4th Tutorial about the basic Windows Programming. Hot key are such key which we embed is in our application for ease of user. For example when we write a URL in browser we write Google and then press Ctrl+Enter then URL look like this http://www.google.com it’s a basic example. we use Alt+F4 to close any kind of window. If you never done this before then your may be thinking that it is very difficult but dear you will surprise to know that its so much easy to create a Hot Key in Windows Application with Csharp.

sabre-oled

How To Use Timer Control In C# Windows Application

This is my second post about the basic controls which we use in C# windows Application. Timer is used to collect the time span of an event to be occurred or to fix certain time span for any event to be occurred or to close any event after certain time. Now its up to you, how you use it.
  

How to use Progress Bar Tool With C# Windows Application

Progress Bar tool is the one of the basic tool which we use in desktop application to make it more professional. Basic purpose of Progress Bar is to show that the Application is in working form not hanged.

pb

Microsoft Web Platform Installer 2.0

The Microsoft Web Platform Installer 2.0 (Web PI) is a free tool that makes getting the latest components of the Microsoft Web Platform, including Internet Information Services (IIS), SQLServer Express, .NET Framework and Visual Web Developer easy.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Powered by Blogger