Dinesh Santhalingam

Dinesh Santhalingam

  • NA
  • 737
  • 357.3k

How to return the value from a class ?

Jan 25 2017 2:00 AM
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using program1; //My progrm file  
  6. static void Main(string[] args)  
  7.         {  
  8.             program1.bike_details details = new bike_details ();  //First class
  9.             program1.userdetails datum = new userdetails();  //second class
  10.             details.bikedata(@"D:\solution");  
  11.             Console.WriteLine("Your output were extracted.......");  
  12.             Console.WriteLine("Press any key to exit.......");  
  13.             Console.ReadKey();  
  14.         }  
My first class file:
  1.  class bike_details  
  2.      {  
  3.             public string Nameofbike { get; set; } //Variable declaration  
  4.             public int bikeIssued { get; set; }  
  5.             public int currentusage { get; set; }  
  6.              
  7.             public void bikedata(string path)//Input from program  
  8.             {  
  9.                      userdetails udetail = new userdetails();//My another class  
  10.                        string bikname;  
  11.                         int no of bike;  
  12.                         int currentbike;  
  13.                        //do something....  
  14.                       udetail.userdata(Nameofbike); 
  15.                      //get the elemnts  from userdata and return it to main function
  16.             }  
  17. }  
My Second class file: 
  1. class userdetails  
  2.    {  
  3.   
  4.        public string UserId { get; set; }  
  5.        public string Username { get; set; }  
  6.         
  7.       public void userdata(string nameofbike)//Input from class1   
  8.        {  
  9.             string userid;  
  10.             string name;  
  11.         //do something....  
  12.         //Add it in a array and return the values   
  13.        }  
 I have a main function.I have created two classes in separate file .Initially i sent the input for class1 from main function.And from there i sent a data to my second class,Where some operation performed and I want to get that data in class2 file in my current class and return to main function.Give me some guidance.
 

Answers (2)