اذهب إلى المحتوى
  • 0

C# مشكلة في دالة البناء

محمد خالد51

السؤال

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class car {


       private int ID;
        private string Color;
        private string Model;
        //الخصائص
        public int ID_privatee
        {
            get { return ID; }
            set { this.ID = value; }
        }
        public string Color_privatee
        {
            get { return Color; }
            set { this.Color = value; }
        }
        public string Model_privatee
        {
            get { return Model; }
            set { this.Model = value; }
        }
        public void information(int ID, string Color, string Model)
        {
           this. ID = ID;
          this.  Color = Color;
           this. Model = Model;
        }

        public void information()

        {
            information(95," blue", "once");
            }
        public void showd()
        {
            Console.WriteLine("this is ID:{0}\n this is color:{1}\nthis is model:{2}", ID, Model, Color);
        }
            


    }
         

    class Program
    {
        static void Main(string[] args)
        {                //Car  ما هي اشكاليته 
            car mycar = new car (123, "blue", "nine");
            Console.WriteLine();



                 
        }
    }
}

 

تم التعديل في بواسطة Wael Aljamal
توضيح السؤال
رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 1
بتاريخ 9 ساعات قال محمد خالد19:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class car {


       private int ID;
        private string Color;
        private string Model;
        //الخصائص
        public int ID_privatee
        {
            get { return ID; }
            set { this.ID = value; }
        }
        public string Color_privatee
        {
            get { return Color; }
            set { this.Color = value; }
        }
        public string Model_privatee
        {
            get { return Model; }
            set { this.Model = value; }
        }
        public void information(int ID, string Color, string Model)
        {
           this. ID = ID;
          this.  Color = Color;
           this. Model = Model;
        }

        public void information()

        {
            information(95," blue", "once");
            }
        public void showd()
        {
            Console.WriteLine("this is ID:{0}\n this is color:{1}\nthis is model:{2}", ID, Model, Color);
        }
            


    }
         

    class Program
    {
        static void Main(string[] args)
        {                //Car  ما هي اشكاليته 
            car mycar = new car (123, "blue", "nine");
            Console.WriteLine();



                 
        }
    }
}

السلام عليكم انت لم تضع ال constractor في كلاس ال  car  و ناديت عليه في دالة ال main

 

بتاريخ 9 ساعات قال محمد خالد19:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class car {


       private int ID;
        private string Color;
        private string Model;
        //الخصائص
      public car( int ID , string Color , string Model){
       this.ID = ID ; 
        this.Color = Color ; 
        this.Model = Model;
      }//هذا هو تصحيح الخطا بالتوفيق اخي 
        public int ID_privatee
        {
            get { return ID; }
            set { this.ID = value; }
        }
        public string Color_privatee
        {
            get { return Color; }
            set { this.Color = value; }
        }
        public string Model_privatee
        {
            get { return Model; }
            set { this.Model = value; }
        }
        public void information(int ID, string Color, string Model)
        {
           this. ID = ID;
          this.  Color = Color;
           this. Model = Model;
        }

        public void information()

        {
            information(95," blue", "once");
            }
        public void showd()
        {
            Console.WriteLine("this is ID:{0}\n this is color:{1}\nthis is model:{2}", ID, Model, Color);
        }
            


    }
         

    class Program
    {
        static void Main(string[] args)
        {                     //ما هي المشكله
            car mycar = new /*car*/ (123, "blue", "nine");// هنا الخطا اذهب الى كلاس الكلاس لقد صححت الخطا 
            Console.WriteLine();



                 
        }
    }
}

 

مشكله.bmp

اتمنى

بتاريخ الآن قال زكرياء سيلم:

 

 

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 7 دقائق مضت قال Wael Aljamal:

أرجو شرح المشكلة مع وضع صورة للخطأ

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class car {


       private int ID;
        private string Color;
        private string Model;
        //الخصائص
        public int ID_privatee
        {
            get { return ID; }
            set { this.ID = value; }
        }
        public string Color_privatee
        {
            get { return Color; }
            set { this.Color = value; }
        }
        public string Model_privatee
        {
            get { return Model; }
            set { this.Model = value; }
        }
        public void information(int ID, string Color, string Model)
        {
           this. ID = ID;
          this.  Color = Color;
           this. Model = Model;
        }

        public void information()

        {
            information(95," blue", "once");
            }
        public void showd()
        {
            Console.WriteLine("this is ID:{0}\n this is color:{1}\nthis is model:{2}", ID, Model, Color);
        }
            


    }
         

    class Program
    {
        static void Main(string[] args)
        {                     //ما هي المشكله
            car mycar = new /*car*/ (123, "blue", "nine");
            Console.WriteLine();



                 
        }
    }
}

 

مشكله.bmp

اتمنى المساعده

تم التعديل في بواسطة محمد خالد19
رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 17 دقائق مضت قال محمد خالد19:

المساعده

أرجو الإنتباه لرسالة الخطأ البرمجية التي تكتب في محرر الأكواد، حيث بعد تجريب البرنامج، تبين أن الخطا يقول أنك لم تفم بتعريف دالة بناء Constructer تستقبل 3 وسطاء.

حيث أن الدالة البانية لها نفس اسم الصنف أي car و تعمل set للقيم الممرة، مثل الدالة information لديك لكن باسم الصنف نفسه car، أرجو تعديل البرنامج و إضافة الدالة البانية، و قراءة رسالة الخطأ بتمعن فهي تدل على المشكلة.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 6 ساعات قال محمد خالد19:

أتمنى الشرح لم افهم

عليك مراجعة دروس دوال البناء في #C.

حيث انها التوابع المعرفة في الأصناف المسؤولة عن بناء الأغراض.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...