Click here to Skip to main content
15,511,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

This is my code

SQL
public class Test : IPerl
    {
        public void Read()
        {
            Console.WriteLine("Read");
        }
    }



C#
public interface IPerl
    {
        void Read();
    }



This another file

C#
static void Main()
        {
            IPerl perl = new Test();
            perl.Read();
        }


Now i want the out of the following line
C#
perl.Read();


is it possible?? I don't know how to and i am using Visual Studio
Please let me know .

Thanks.
Posted
Comments
VJ Reddy 17-May-12 1:48am    
Thank you for accepting the solution.

If your purpose is to read from Console and return the input as a string, then the Read method in IPerl interface may be made to return a string and other modifications may be made as follows:
C#
using System;

namespace ReadFromConsole {
    class Program {
        static void Main(string[] args) {
            IPerl perl = new Test();
			Console.WriteLine (perl.Read());
            Console.ReadKey();
        }
    }
    public class Test : IPerl {
        public string Read() {
            var conkeyinfo = Console.ReadLine();
            return conkeyinfo.ToString();
        }
    }

    public interface IPerl {
        string Read();
    }
}
 
Share this answer
 
Comments
Sandeep Mewara 17-May-12 1:08am    
5!
VJ Reddy 17-May-12 1:12am    
Thank you, Sandeep :)
member60 17-May-12 23:52pm    
my 5!
VJ Reddy 18-May-12 0:21am    
Thank you, member60 :)
See this link You Will Get Some IDea
Interfaces in C# (For Beginners)[^]
 
Share this answer
 
Comments
Sipherz 17-May-12 1:36am    
I saw.. thanx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900