C# 名前付きパラメーター

using System;

namespace TestNamespace
{
internal class HP
{
public int CalcAdd2(int a, int b, int c)
{
return a + b + c;
}
}

class Program
{
    static void Main(string[] args)
    {
        HP test = new HP();

        int a = test.CalcAdd2(a: 3, b: 4, c: 2);

        int b = test.CalcAdd2(a: 3, b: 1, c: 2);

        Console.WriteLine(a);
        Console.WriteLine(b);
    }
}

}

C# class

using System;
using System.ComponentModel.DataAnnotations;

namespace Chap3
{
class Car
{
public string name;
public int seats = 4;
}
class MainClass
{
static void Main()
{
Car mycar1 = new Car();
Car mycar2 = new Car();

        //インスタンス
        Console.WriteLine(mycar1 == mycar2);

        mycar1.name = "メイン";
        mycar2.name = "サブ";

        Console.WriteLine(mycar1.name);
        Console.WriteLine(mycar2.name);
    }
}

}

C# 問題集

using System;

namespace BoardGame
{
class Program
{
static void Main(string[] args)
{
// Read input
string[] dimensions = Console.ReadLine().Split();
int H = int.Parse(dimensions[0]);
int W = int.Parse(dimensions[1]);

        char[][] board = new char[H][];
        for (int i = 0; i < H; i++)
        {
            board[i] = Console.ReadLine().ToCharArray();
        }

        string[] coordinates = Console.ReadLine().Split();
        int y = int.Parse(coordinates[0]);
        int x = int.Parse(coordinates[1]);

        // Modify the board
        if (board[y][x] == '.')
        {
            board[y][x] = '#';
        }
        else if (board[y][x] == '#')
        {
            board[y][x] = '.';
        }

        // Output the modified board
        for (int i = 0; i < H; i++)
        {
            Console.WriteLine(new string(board[i]));
        }
    }
}

}

敵を作ってみよう・その2【Unity 2Dアクションの作り方】【初心者入門講座】【ゲームの作り方】#45

今回は敵キャラクターを作ってみましたが、アニメーションがうまく動かなかったです

【C#】string型とchar型

using System;

class string01
{
    public static void Main()
    {
        char[] chararray = new char[3];
        chararray[0] = 'a';
        chararray[1] = 'b';
        chararray[2] = 'c';

        string str;
        str = new string(chararray);
        Console.WriteLine(str);

        char[] title = { 'a', 'i', 'u', 'e', 'o', 'k' };
        string strTitle = new string(title);
        Console.WriteLine(strTitle);


        string strx = "C#プログラム";
        int n = strx.Length;
        Console.WriteLine("「{0}」の文字数は{1}です", strx, n);

        char c = strx[1];
        Console.WriteLine("「{0}」の2番目の文字は「{1}」です", strx, c);


    }
}

C# 変数の型

using System;

class MyApp
{

static void Main()
{
// 変数: 再代入が可能
// 定数: 再代入が不可能
string s = “hello”;
char c = ‘a’;

int i = 100;

double d = 52342.34;
float f = 23.3f;

//論理
bool flag = true;

var x = 5;
var y = “world”;
}

}