Answers for "struct constructor c#"

C#
1

how to make custom struct C#

struct Parts
    {
        public static Parts NewPart(string PartName, string strName, int PartId)
        {
            return new Parts
            {
                Part = PartName,
                Name = strName,
                Id = PartId
            };
        }
        public string Part { get; set; }
        public string Name { get; set; }
        public string Id { get; set; }
    }
Posted by: Guest on December-03-2020
4

c# struct

public struct Coords
{
    public Coords(double x, double y)
    {
        X = x;
        Y = y;
    }

    public double X { get; }
    public double Y { get; }

    public override string ToString() => $"({X}, {Y})";
}
Posted by: Guest on April-15-2020
0

struct constructor c#

struct Coordinate
{
    public int x;
    public int y;

    public Coordinate(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}
Posted by: Guest on June-18-2021

C# Answers by Framework

Browse Popular Code Answers by Language