Click here to Skip to main content
15,889,403 members
Home / Discussions / C#
   

C#

 
Questionproblem with converting to Double Pin
Rick van Woudenberg6-Jul-08 7:01
Rick van Woudenberg6-Jul-08 7:01 
AnswerRe: problem with converting to Double Pin
Deresen6-Jul-08 7:13
Deresen6-Jul-08 7:13 
AnswerRe: problem with converting to Double Pin
Luc Pattyn6-Jul-08 7:23
sitebuilderLuc Pattyn6-Jul-08 7:23 
QuestionHow Do I Save the Contents of a WebPage without using A WebBrowser? Pin
That Asian Guy6-Jul-08 6:40
That Asian Guy6-Jul-08 6:40 
AnswerRe: How Do I Save the Contents of a WebPage without using A WebBrowser? Pin
Luc Pattyn6-Jul-08 7:24
sitebuilderLuc Pattyn6-Jul-08 7:24 
QuestionCheck for the status of Windows Form Pin
ASysSolvers6-Jul-08 4:21
ASysSolvers6-Jul-08 4:21 
AnswerRe: Check for the status of Windows Form Pin
Luc Pattyn6-Jul-08 4:43
sitebuilderLuc Pattyn6-Jul-08 4:43 
QuestionIs Interface implementation Correct Pin
Navneet Hegde6-Jul-08 3:37
Navneet Hegde6-Jul-08 3:37 
Dear All,
To know the IEnumerable Interface I have done one demo Aplication please let me know whether there is anything wrong in my approach.

class MyFile : FileSystemInfo
 {
     private FileInfo _strFile;
     public MyFile(FileInfo strFile)
     {
         _strFile = strFile;
     }

     public override void Delete()
     {
         _strFile.Delete();
     }

     public override bool Exists
     {
         get
         {
             if (_strFile.Exists)
             {
                 return true;
             }
             else
             {
                 return false;
             }

         }
     }

     public override string Name
     {
         get { return _strFile.Name;}
     }
 }

class MyFiles : IEnumerable<MyFile>
 {
     private string _directoryPath;
     private string _fileExtension = "xml";

     public MyFiles(string directoryPath)
     {
         _directoryPath = directoryPath;
     }

     public string FileExtension
     {
         get { return _fileExtension; }
         set { _fileExtension = value; }
     }

     #region IEnumerable<MyFile> Members

     public IEnumerator<MyFile> GetEnumerator()
     {
         DirectoryInfo di = new DirectoryInfo(_directoryPath);
         FileInfo[] rgFiles = di.GetFiles("*." + _fileExtension);
         foreach (FileInfo fi in rgFiles)
         {
             MyFile ss = new MyFile(fi);
             yield return ss;
         }
     }

     #endregion

     #region IEnumerable Members

     IEnumerator IEnumerable.GetEnumerator()
     {
         DirectoryInfo di = new DirectoryInfo(_directoryPath);
         FileInfo[] rgFiles = di.GetFiles("*." + _fileExtension);
         foreach (FileInfo fi in rgFiles)
         {
             MyFile ss = new MyFile(fi);
             yield return ss;
         }
     }

     #endregion

 }



Here is it's implementation :

static void Main()
   {
       MyFiles myFS = new MyFiles(@"D:\TestInterface");
       foreach(MyFile FS in MyFiles)
       {
           Console.WriteLine(FS.Name);
           Console.ReadLine();
       }

   }



Here I am trying to Iterate the Files in Certain directory, and it's further implementation would be to Add New Methods to MyFile Class so as to get Certain required Data from the Files.So far it looks good .
I only wanted to know whether my Interface Implementation is Wrong anywhere or require any changes.

Thanks in Advance.

Develop2Program & Program2Develop

AnswerRe: Is Interface implementation Correct Pin
leppie6-Jul-08 3:52
leppie6-Jul-08 3:52 
Questioncan i drive a class from a delegate Pin
Pankaj Garg6-Jul-08 3:29
Pankaj Garg6-Jul-08 3:29 
AnswerRe: can i drive a class from a delegate Pin
leppie6-Jul-08 3:53
leppie6-Jul-08 3:53 
AnswerRe: can i drive a class from a delegate Pin
leppie6-Jul-08 3:55
leppie6-Jul-08 3:55 
GeneralRe: can i drive a class from a delegate Pin
Pete O'Hanlon6-Jul-08 8:55
mvePete O'Hanlon6-Jul-08 8:55 
GeneralRe: can i drive a class from a delegate Pin
leppie6-Jul-08 9:17
leppie6-Jul-08 9:17 
GeneralRe: can i drive a class from a delegate Pin
Pete O'Hanlon6-Jul-08 9:24
mvePete O'Hanlon6-Jul-08 9:24 
GeneralRe: can i drive a class from a delegate Pin
leppie6-Jul-08 9:45
leppie6-Jul-08 9:45 
AnswerRe: can i drive a class from a delegate Pin
N a v a n e e t h6-Jul-08 4:05
N a v a n e e t h6-Jul-08 4:05 
QuestionC# WINFORMS' Threading Apllication halt while Desktop Theme Change Pin
S Raheel Noor6-Jul-08 3:11
S Raheel Noor6-Jul-08 3:11 
QuestionApplied Application Development - Book recommendation sought [modified] Pin
DwR6-Jul-08 2:29
DwR6-Jul-08 2:29 
AnswerRe: Applied Application Development - Book recommendation sought Pin
DwR6-Jul-08 23:26
DwR6-Jul-08 23:26 
Questionerror display variable value/type Pin
George_George6-Jul-08 2:13
George_George6-Jul-08 2:13 
AnswerRe: error display variable value/type Pin
Christian Graus6-Jul-08 9:21
protectorChristian Graus6-Jul-08 9:21 
GeneralRe: error display variable value/type Pin
George_George6-Jul-08 16:04
George_George6-Jul-08 16:04 
GeneralRe: error display variable value/type Pin
leppie6-Jul-08 21:11
leppie6-Jul-08 21:11 
GeneralRe: error display variable value/type Pin
George_George6-Jul-08 21:31
George_George6-Jul-08 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.