小编Tri*_*son的帖子

如何创建平铺系统

不是为每个瓷砖创建单独的案例,更好的方法是什么?

public void Draw(SpriteBatch spriteBatch, Level level)
    {
        for (int row = 0; row < level._intMap.GetLength(1); row++) {
            for (int col = 0; col < level._intMap.GetLength(0); col++) {
                switch (level._intMap[col, row]) {
                    case 0:
                        spriteBatch.Draw(_texture, new Rectangle(row * _tileWidth, col * _tileHeight, _tileWidth, _tileHeight), new Rectangle(0 * _tileWidth, 0 * _tileHeight, _tileWidth, _tileHeight), Color.White);
                        break;
                    case 1:
                        spriteBatch.Draw(_texture, new Rectangle(row * _tileWidth, col * _tileHeight, _tileWidth, _tileHeight), new Rectangle(1 * _tileWidth, 0 * _tileHeight, _tileWidth, _tileHeight), Color.White);
                        break;
                    case 2: …
Run Code Online (Sandbox Code Playgroud)

c# xna

1
推荐指数
1
解决办法
888
查看次数

无法将参数值从SqlParameter转换为String

我收到错误:

无法将参数值从SqlParameter转换为String.

我传入:

TestUsername,
TestPassword,
TestFirstName,
TestLastName,
TestEmail@Email.Com
Run Code Online (Sandbox Code Playgroud)

码:

        try
        {

            Console.WriteLine("Inputs: Username, Password, First Name, Last Name, Email");
            Console.WriteLine("Username: ");
            string usernameInput = Console.ReadLine();
            Console.WriteLine("Password: ");
            string passwordInput = Console.ReadLine();
            Console.WriteLine("First Name: ");
            string firstNameInput = Console.ReadLine();
            Console.WriteLine("Last Name: ");
            string lastNameInput = Console.ReadLine();
            Console.WriteLine("Email: ");
            string emailInput = Console.ReadLine();

            SqlCommand createLogin = new SqlCommand("INSERT INTO [dbo].[Users] VALUES ('@username', '@password', '@firstname', '@lastname', '@email')", myConnection.SqlConnection);
            SqlParameter usernameParam = createLogin.Parameters.Add("@username", SqlDbType.VarChar, 40);
            SqlParameter passwordParam = createLogin.Parameters.Add("@password", SqlDbType.VarChar, 50);
            SqlParameter firstNameParam = …
Run Code Online (Sandbox Code Playgroud)

.net c# t-sql sql-server

1
推荐指数
1
解决办法
5479
查看次数

数组值不变?

由于某种原因,这不会编辑输入到其中的数组的大小,并且数据不会添加到输入的数组中.

    public static void RandomizeArray(int[] array)
    {
        int intRead;
        int intReadSeed;
        Random randomNum = new Random();
        Console.WriteLine("How many ints do you want to randomly generated?");
        intRead = Convert.ToInt32(Console.ReadLine());
        array = new int[intRead];
        Console.WriteLine("What's the maximum value of the randomly generated ints?");
        intReadSeed = Convert.ToInt32(Console.ReadLine());
        for (int i = 0; i < intRead; i++)
        {
            array[i] = (randomNum.Next(intReadSeed));
        }
        Console.WriteLine("Randomization Complete.\n");
    }
Run Code Online (Sandbox Code Playgroud)

c#

1
推荐指数
1
解决办法
938
查看次数

标签 统计

c# ×3

.net ×1

sql-server ×1

t-sql ×1

xna ×1