小编bra*_*ry9的帖子

我如何在StartsWith中使用toLower

我需要你的帮助。
我希望用户输入搜索对象列表。
在此,用户应指定对象的首字母。

现在的问题是,由于某些词要大写,而其他词要小写,因此我想进行调整,以便用户输入和列表中的对象始终都用小写。

我以为您也许可以做到这一点,toLower但这在列表对象上不起作用。
顺便提及,列表对象是字符串。

是否有一个简单的解决方案,toLower或者如何做到最好?

Console.WriteLine("Please enter the first Letter");

string search = Console.ReadLine().ToLower();

Console.Clear();

foreach(var erg in speichert)
{
    if (erg.B_NAME.ToLower().StartsWith(search))
    {
        Console.WriteLine("something");
    }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

使用 textmesh pro 设置文本

有没有办法用textmesh脚本循环文本?

我对循环文本感兴趣,这样我就可以在 2D 游戏中显示不同的文本。

我已经尝试过这个网站上的脚本。但我认为这不起作用。也许我做错了什么?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class CyclingText : MonoBehaviour
{
    public TMP_Text text;
    void Update()
    {
        TextMeshPro textmeshPro = GetComponent<TextMeshPro>();
        textmeshPro.SetText("The first number is {0} and the 2nd is {1:2} and the 3rd is {3:0}.", 4, 6.345f, 3.5f);
        // The text displayed will be:
        // The first number is 4 and the 2nd is 6.35 and the 3rd is 4.
    }   
}
Run Code Online (Sandbox Code Playgroud)

有人可以给我答案或解释我做错了什么吗?

c# string unity-game-engine

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

没有 setter 的属性如何允许赋值?

在 C# 中,可以使用 getter 和 setter 来声明属性。如果没有设置器那么它不应该允许设置?

但是这个 .net core 3.1 示例教程显示了分配给此类属性的值。这怎么被允许呢?

代码:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }
      
    public IConfiguration Configuration {get;}
}
Run Code Online (Sandbox Code Playgroud)

c#

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

C# 获取参数名称的方法

在C#中如何获取方法调用的参数名称?

例子:

public static void PrintList (List<string> list)
{
    Console.WriteLine("\n");
    foreach (var item in list)
    {
        Console.WriteLine(item);
    }
    Console.WriteLine("\n");
}

PrintList(oxygenList);
Run Code Online (Sandbox Code Playgroud)

我需要打印的方法:

氧气清单

谢谢。

c#

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

标签 统计

c# ×4

string ×1

unity-game-engine ×1