filmov
tv
C# overloaded constructors 🍕
Показать описание
C# overloaded constructors tutorial example explained
#C# #overloaded #constructors
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// overloaded constructors = technique to create multiple constructors,
// with a different set of parameters.
// name + parameters = signature
Pizza pizza = new Pizza("stuffed crust", "red sauce", "mozzarella");
Console.ReadKey();
}
}
class Pizza
{
String bread;
String sauce;
String cheese;
String topping;
public Pizza(String bread)
{
}
public Pizza(String bread, String sauce)
{
}
public Pizza(String bread, String sauce, String cheese)
{
}
public Pizza(String bread, String sauce, String cheese, String topping)
{
}
}
}
#C# #overloaded #constructors
using System;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
// overloaded constructors = technique to create multiple constructors,
// with a different set of parameters.
// name + parameters = signature
Pizza pizza = new Pizza("stuffed crust", "red sauce", "mozzarella");
Console.ReadKey();
}
}
class Pizza
{
String bread;
String sauce;
String cheese;
String topping;
public Pizza(String bread)
{
}
public Pizza(String bread, String sauce)
{
}
public Pizza(String bread, String sauce, String cheese)
{
}
public Pizza(String bread, String sauce, String cheese, String topping)
{
}
}
}
Комментарии