This example will help you understand how to extract matched data using regular expressions and display it on the console.
Watch this tutorial first on using BackReferences:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace Regex1
{
class Program
{
static void Main(string[] args)
{
string htmlfile = CreateString();
DisplayMatches(htmlfile);
Console.ReadKey();
}
static string CreateString()
{
FileStream fs = new FileStream(@"C:\Users\Ship\Documents\Visual Studio 2008\Projects\Regex1\Regex1\Sample.aspx", FileMode.Open);
StreamReader sr = new StreamReader(fs);
string s = sr.ReadToEnd();
return s;
}
static void DisplayMatches(string s)
{
Regex r;
Match m;
r = new Regex(@"href\s*=\s*(?:""(?<1>[^""]*)""|(?<1>\S+))", RegexOptions.IgnoreCase|RegexOptions.Compiled);
for (m = r.Match(s); m.Success; m = m.NextMatch())
{
Console.WriteLine("Found href " + m.Groups[1] + " at "
+ m.Groups[1].Index);
}
}
}
}
Video tutorial for this post will be uploaded soon.
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Free Online Training VIDEOS,SAMPLES,TUTORIALS ON MCTS EXAM C#.NET(MS VISUAL STUDIO) Thanks for your support. The blog is getting bigger and better day by day. please check out : www.blog.sameershaik.com for further interesting articles on other microsoft certification examinations
Search this blog
You can search for all the topics in our blog using our google custom search now.
Search the blog
Loading
Tuesday, August 24, 2010
Wednesday, August 18, 2010
Topic : Serialization
These are the list of posts related to Serialization Topic :
1.How to serialize and de-serialize simple objects Part - 1
2.How to serialize and de-serialize simple objects Part - 2
3.Creating a serializable class and Writing it to a file
4.Soap Serialization using a serializable class
5.Xml Serialization and De-Serialization Example
1.How to serialize and de-serialize simple objects Part - 1
2.How to serialize and de-serialize simple objects Part - 2
3.Creating a serializable class and Writing it to a file
4.Soap Serialization using a serializable class
5.Xml Serialization and De-Serialization Example
Regards
Sameer Shaik
Monday, August 16, 2010
Monitoring File System
Hi,
I have done a simple tutorial on monitoring file systems. Please watch the video tutorials which is split in three parts:
Ads By Google
Part -- 1 :-
Part -- 2 :-
Part -- 3 :-
The code for the tutorial is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace MonitorFilesExample
{
class Program
{
static void Main(string[] args)
{
Run();
}
public static void Run()
{
FileSystemWatcher Watcher = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));
Watcher.Path = @"C:\My stuff\Work Stuff\Vship";
Watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
Watcher.Filter = "*.txt";
//Add event handlers for all the events
Watcher.Changed += new FileSystemEventHandler(Watcher_Changed);
Watcher.Renamed += new RenamedEventHandler(Watcher_Renamed);
Watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted);
Watcher.EnableRaisingEvents = true;
Console.ReadKey();
}
static void Watcher_Deleted(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File : " + e.FullPath + " Change Type is : " + e.ChangeType);
}
static void Watcher_Renamed(object sender, RenamedEventArgs e)
{
Console.WriteLine("File : " + e.FullPath + " Change Type is : " + e.ChangeType);
}
static void Watcher_Changed(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File : "+e.FullPath+ " Change Type is : "+ e.ChangeType);
}
}
}
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
I have done a simple tutorial on monitoring file systems. Please watch the video tutorials which is split in three parts:
Ads By Google
Part -- 1 :-
Part -- 2 :-
Part -- 3 :-
The code for the tutorial is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace MonitorFilesExample
{
class Program
{
static void Main(string[] args)
{
Run();
}
public static void Run()
{
FileSystemWatcher Watcher = new FileSystemWatcher(Environment.GetEnvironmentVariable("USERPROFILE"));
Watcher.Path = @"C:\My stuff\Work Stuff\Vship";
Watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName;
Watcher.Filter = "*.txt";
//Add event handlers for all the events
Watcher.Changed += new FileSystemEventHandler(Watcher_Changed);
Watcher.Renamed += new RenamedEventHandler(Watcher_Renamed);
Watcher.Deleted += new FileSystemEventHandler(Watcher_Deleted);
Watcher.EnableRaisingEvents = true;
Console.ReadKey();
}
static void Watcher_Deleted(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File : " + e.FullPath + " Change Type is : " + e.ChangeType);
}
static void Watcher_Renamed(object sender, RenamedEventArgs e)
{
Console.WriteLine("File : " + e.FullPath + " Change Type is : " + e.ChangeType);
}
static void Watcher_Changed(object sender, FileSystemEventArgs e)
{
Console.WriteLine("File : "+e.FullPath+ " Change Type is : "+ e.ChangeType);
}
}
}
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Friday, August 6, 2010
Using Enumerations
Enumerations:
An enumeration is a user - defined integer type. When you declare an enumeration, you specify a set of acceptable values that instances of that enumeration can contain. Not only that, but you can give the values user - friendly names.
color skyblue = color.blue;
int code = (int) Enum.Parse(typeof(color),skyblue.ToString());
if (code == 101010)
{
Console.WriteLine("The color you have chosen is "+skyblue+" and the color code is "+ code.ToString());
Console.ReadKey();
}
}
public enum color
{
blue = 101010,
black = 000000,
white = 111111
}
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Monday, August 2, 2010
Configuring Applications
Why do you need to configure your application?
A. Once you finish creating an application, you would want to save some settings like user settings or database connection settings or information stored between different sessions etc etc. Though dot net takes cares of most of the applications settings in machine.config file, we can always override the settings in machine.config file by creating a custom config file for our application.
In this example we will see how to create our own .config file for our application and configure the .config file for our application requirements.
Video Tutorial Part -- 1
Video Tutorial Part --2
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
A. Once you finish creating an application, you would want to save some settings like user settings or database connection settings or information stored between different sessions etc etc. Though dot net takes cares of most of the applications settings in machine.config file, we can always override the settings in machine.config file by creating a custom config file for our application.
In this example we will see how to create our own .config file for our application and configure the .config file for our application requirements.
Video Tutorial Part -- 1
Video Tutorial Part --2
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Value Types V/S Reference Types
Value Types and Reference Types:
- Value types are defined from System.ValueType while the reference types are derived from System.Object.
- The stack holds the value type variables along with return addresses.
- The heap holds the reference type variables value.
Copying Value Types Variables:
- If you copy one value type variable from another, a direct copy of variable value is made.
- If you are curious how is it created on stack, then this is how it is looks on stack:
- So now when we copy the value of a to b by using the following statement:
4. Value of a is directly copied to b.
Copying Reference Type Variables:
- Lets create a variable of type reference. String is a built-in reference type, we will create an object of string and assign some value to it as follows:
Regards
Sameer Shaik
Tags: Microsoft MCTS exam, Learn, Tutorials, Free C#, Free Videos, Microsoft Dot Net Jobs,Microsoft Dot Net Jobs Interview, Free Training and Preparation, Jobs MCTS specialization, visual studio.net, study guide, sample questions, Exam Prep, Exam Practice Test
Subscribe to:
Posts (Atom)