hi thank and am sorry for using urgently, am also sorry if you were not able to understand my question. the bit of the program works well for the part of reading the text file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;
using ConsoleApplication1;
namespace trial1
{
class Program
{
static void Main(string[] args)
{
StreamReader streamReader = new StreamReader("D:\\semantic.txt");
int block = 0;
while (!streamReader.EndOfStream)
{
string line = streamReader.ReadLine().Trim();
if (line.CompareTo("") == 0)
{
continue;
}
if (line.CompareTo("#1") == 0)
{
Console.WriteLine("We have #1");
block = 1;
continue;
}
if (line.CompareTo("#2") == 0)
{
Console.WriteLine("\n\nWe have #2");
block = 2;
continue;
}
if (line.CompareTo("#3") == 0)
{
Console.WriteLine("\n\nWe have #3");
block = 3;
continue;
}
if (block == 1)
{
string[] first = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (first.Length == 2)
{
int code = Convert.ToInt32(first[0].Trim());
string name = first[1].Trim();
Console.WriteLine("code = {0}, name = '{1}'", code, name);
}
}
if (block == 2)
{
string[] second = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (second.Length == 3)
{
int code = Convert.ToInt32(second[0].Trim());
string connector = second[1].Trim();
int code2 = Convert.ToInt32(second[2].Trim());
Console.WriteLine("code = {0}, connector = '{1}', code2 = {2}", code, connector, code2);
}
}
if (block == 3)
{
string[] third = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (third.Length == 3)
{
int name = Convert.ToInt32(third[0].Trim());
int code2 = Convert.ToInt32(third[1].Trim());
int name1 = Convert.ToInt32(third[2].Trim());
Console.WriteLine("name = {0}, code2 = {1}, name1 = {2}", name, code2, name1);
}
}
}
streamReader.Close();
What i am asking is i need to add part of code which takes in user input in any of the following formats and gives otput that corresponds within #3:
for example if user enters
?:?:?- it will display the whole #3
10:?:? - it will display all lines in #3 that start with 10
10:4:11 - it will give output as true
thats my problem. hope i was able to make you understand. thank you