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

ابي حل لهذه بلغة السي شارب

An1.

السؤال

Recommended Posts

  • 0

أهلًا بك،

الحل يمكن أن يكون كالتالي

namespace NewOperator { 

class Rectangle { 

	public int length, breadth; 

	// Parameterized Constructor 
	// User defined 
	public Rectangle(int l, int b) 
	{ 
		length = l; 
		breadth = b; 
	} 

	// Method to Calculate Area 
	// of the rectangle 
	public int Area() 
	{ 
		return length * breadth; 
	} 
} 

// Driver Class 
class Program { 

	// Main Method 
	static void Main(string[] args) 
	{ 
		// Creating an object using 'new' 
		// Calling the parameterized constructor 
		// With parameters 10 and 12 
		Rectangle rect1 = new Rectangle(10, 12); 
       		 // To display length and breadth of the Rectangle 
		int length = rect1.length;
		int breadth = rect1.breadth;
		Console.WriteLine("The length of the"+ 
				" Rectangle is " + length); 
		Console.WriteLine("The breadth of the"+ 
				" Rectangle is " + breadth); 
		// To display are of the Rectangle 
		int area = rect1.Area(); 
		Console.WriteLine("The area of the"+ 
				" Rectangle is " + area); 
	} 
} 

 

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

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

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

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

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   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.

  • إعلانات

  • تابعنا على



×
×
  • أضف...