Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 255803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:57:40+00:00 2026-05-11T21:57:40+00:00

I have been scratching my head over this for days and I still cannot

  • 0

I have been scratching my head over this for days and I still cannot understand how to implement this interface.

Here is my code:

namespace ConsoleApplication32 {
public static class ScanAndSerialize
{

    public static void Serialize()
    {

        List<string> dirs = FileHelper.GetFilesRecursive("s:\\");
        List<string> dirFiles = new List<string>();
        foreach (string p in dirs)
        {
            string path = p;
            string lastAccessTime = File.GetLastAccessTime(path).ToString();
            bool DirFile = File.Exists(path);
            DateTime lastWriteTime = File.GetLastWriteTime(p);
            //dirFiles.Add(p + " , " + lastAccessTime.ToString() + " , " + DirFile.ToString() + " , " + lastWriteTime.ToString());
            dirFiles.Add(p);
            dirFiles.Add(lastAccessTime);
            dirFiles.Add(DirFile.ToString());
            dirFiles.Add(lastWriteTime.ToString());
            dirFiles.Add(Environment.NewLine);

        }


        XmlSerializer SerializeObj = new XmlSerializer(dirFiles.GetType());
        string sDay = DateTime.Now.ToString("MMdd");
        string fileName = string.Format(@"s:\project\{0}_file.xml", sDay);
        TextWriter WriteFileStream = new StreamWriter(fileName);

        SerializeObj.Serialize(WriteFileStream, dirFiles);
        WriteFileStream.Close();


    }

    static class FileHelper
    {
        public static List<string> GetFilesRecursive(string b)
        {
            // 1.
            // Store results in the file results list.
            List<string> result = new List<string>();

            // 2.
            // Store a stack of our directories.
            Stack<string> stack = new Stack<string>();

            // 3.
            // Add initial directory.
            stack.Push(b);

            // 4.
            // Continue while there are directories to process
            while (stack.Count > 0)
            {
                // A.
                // Get top directory
                string dir = stack.Pop();

                try
                {
                    // B
                    // Add all files at this directory to the result List.
                    result.AddRange(Directory.GetFiles(dir, "*.*"));

                    // C
                    // Add all directories at this directory.
                    foreach (string dn in Directory.GetDirectories(dir))
                    {
                        stack.Push(dn);
                    }
                }
                catch
                {
                    // D
                    // Could not open the directory
                }
            }
            return result;
        }
    }



    public class MyInterface: IValidationRowSet
    {

        public int RowNumber { get; set; }

        public string RowAsString { get; set; }
        public IValidationRowSet MatchedRow { get; set; }
        public string FriendlyNameLabel { get; set; }
        public string KeyFieldLabel { get; set; }
        IList<string> lst = new List<string>();
        public string SourceWorksheetName { get; set; }
        public string SourceRangeName { get; set; }
        //public string SourceRangeName { get; set; }
        public bool bReported { get; set; }

        public int FieldCount { get { return lst.Count; } }
        public string FieldData(int id)
        {
            if (id <= lst.Count)
                return lst[id];
            else
                return null;
        }
        public string ValidationMessage { get; set; }




    }

Here is an explanation of the interface (still scratching my head over this one)

namespace Validation {
/// <summary>
/// Implement this interface if you want the engine to callback when it finds exception
/// messages.  You will pass a reference to you class to the validation engine, and 
/// it will call "PostValidationMessage" for each exception example, including the message,
/// the entire row set of data (vr), and the id of the field that created the exception.
/// </summary>
public interface IValidationReporter
{
/// <param name="sMsg"></param>
/// <param name="vr"></param>
/// <param name="id"></param>
    void PostValidationMessage(string sMsg, IValidationRowSet vr, int id);
}


/// <summary>
/// Implement this interface in order to use the validation engine.
/// The validation engine takes 2 IList<IValidationRowSet> objects and compares them.
/// A class that implements this interface will contain an entire row of data that you'll
/// want to compare.
/// </summary>
public interface IValidationRowSet
{

    /// <summary>
    /// should return an int of the number of fields in this row
    /// </summary>
    int FieldCount { get; }

    /// <summary>
    /// should return an int of the row number that this row is in the set
    /// usually set when the data is assembled
    /// </summary>
    int RowNumber { get; set; }

    /// <summary>
    /// this is a function that should return the field data for this row at zero-indexed location "id"
    /// ex: if the row contains this data: smith|fred|2126782524|fred@smith.com|
    /// a call on this method of FieldData(2) will return the phone number 2126782524
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    string FieldData(int id);

    /// <summary>
    /// this will be modified by the validation process
    /// </summary>
    string ValidationMessage { get; set; }

    /// <summary>
    /// this will be modified by the validation process
    /// </summary>
    IValidationRowSet MatchedRow { get; set; }

    /// <summary>
    /// returns a string that uniquely identifies this row
    /// ex: if the row contains this data: smith|fred|2126782524|fred@smith.com|
    /// so for this example, the unique identifier could be the email address fred@smith.com
    /// </summary>
    string KeyFieldLabel { get; set; }

    /// <summary>
    /// returns a string with the "friendly" name of this row
    /// ex: if the row contains this data: smith|fred|2126782524|fred@smith.com|
    /// so for this example, FriendlyNameLabel could be the name, such as "Fred Smith"
    /// </summary>
    string FriendlyNameLabel { get; set; }

    /// <summary>
    /// returns all fields in the row as pipe delimited
    /// ex: 1,234.23|Fred Smith|Fred@smith.com|
    /// </summary>
    string RowAsString { get; set; }


    /// <summary>
    /// if this is an excel file comparison, this should return the name 
    /// of the worksheet from whence this data came
    /// </summary>
    string SourceWorksheetName { get; set; }


    /// <summary>
    /// if this is an excel file comparison, this should return the name 
    /// of the worksheet range from whence this data came
    /// </summary>
    string SourceRangeName { get; set; }

    /// <summary>
    /// this will be modified by the validation process
    /// </summary>
    bool bReported { get; set; }
}
}

I have read NUMEROUS articles/books/forum postings about Interfaces. This concept feels like a black hole to me…and i’m on a project where i have to implement this. Anybody have ANY idea how the heck you implement this? By the way–i’m a COMPLETE newbie programmer…less than 2 months experience…therefore please do not chastise me for my green-ness please.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:57:40+00:00Added an answer on May 11, 2026 at 9:57 pm

    Consider interfaces to be a prototype or a template for a puzzle to be filled in – think of them as white space and lines where to put the pieces. You will have to derive the interfaces into concrete classes – the pretty picture puzzle.

    Let me save this and I’ll put up an example.

    interface IFoo
    {
        bool DoFoo(int number);
    }
    
    class Foo : IFoo
    {
        public bool DoFoo(int number) {
             return (number++ >= 0); 
        }
    }
    
    class Foo2 : IFoo
    {
        public bool DoFoo(int number) {
             return (number-- >= 0); 
        }
    }
    

    Now that I have that, I can do stuff like this.

    IFoo foo;
    
    if (!value)
        foo = new Foo();
    else
        foo = new Foo2();
    
    bool value2 = foo.DoFoo(27);
    

    Notice, I cannot do this with interfaces:

    // WRONG
    Foo2 foo2 = new Foo();
    

    So that basically sums up what an interface does and how it works. What your job now is to implement those concrete implementations of the interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been scratching my head over this for an hour... I have a list
I've been scratching my head over this one for a couple hours now, I've
Have been scatching my head about this - and I reckon it's simple but
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
For the past eight months or so, I have been banging my head on
I started on a little toy project in C lately and have been scratching
Have been looking at the MVC storefront and see that IQueryable is returned from
Have been studying the file system related classes of Adobe AIR 1.5, but so
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been experimenting with woopra.com A web analytics tool. Which requires a piece

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.