Deutsch

ИИ для программиста?

17.11.24 20:20
Re: ИИ для программиста?
 
AlexNek патриот
AlexNek
в ответ AlexNek 09.11.24 10:23

А что с сайтом случилось? пишет что ветки такой нет. Пока ответ писал


Чёта бинговский ИИ тупит.

А кого вы так называете? смущ Мне выдали следующее

public static string DescribeObject(object obj)
{
    return obj switch
    {
        string s => $"A string with length {s.Length}",
        int i when i > 0 => $"A positive integer: {i}",
        int i => $"A non-positive integer: {i}",
        DateTime { Year: > 2000 } d => $"A date after 2000: {d.ToShortDateString()}",
        DateTime d => $"A date before or in 2000: {d.ToShortDateString()}",
        Person { Name: var name, Age: >= 18 } => $"An adult named {name}",
        Person p => $"A minor named {p.Name}",
        IEnumerable<int> numbers => $"A collection of {numbers.Count()} integers",
        _ => "An object of unknown type"
    };
}
...
public static void Main()
    {
        object input = "Hello, World!"; // Example input
        var result = input switch
        {
            string s => $"String: {s}",
            int i => $"Integer: {i}",
            double d => $"Double: {d}",
            DateTime dt => $"DateTime: {dt}",
            _ => "Unknown type"
        };
        Console.WriteLine(result);
    }

Но проблема пока не доходит смущ

https://learn.microsoft.com/en-us/dotnet/csharp/language-r...

 

Перейти на