C# String vergleich ohne Beachtung der Groß- Kleinschreibung?

Hallo, ich habe seit gestern mit dem progammieren von C# angefangen.

Das Programm "Streamer.bot", das man mit Twitch verbinden kann, unterstützt eigene C# Codes und deshalb bin ich darauf gekommen mit dem "programmieren" anzufangen.

Ich habe einen Code erstellt, in dem ein Input (string msg) mit einer Textdatei (string[] blacklist) verglichen wird. In der Textdatei stehen alle Blacklist Wörter.

Nun bin ich auf das Problem gestoßen, dass die Groß- und Kleinschreibung bei dem vergleich beachtet wird und das ist bei einer Blacklist eher nachteilig.

Meine Frage an dieser Stelle ist, wie ich es schaffe, dass die Groß- und Kleinschreibung bei dem vergleich ignoriert wird.

Ich hoffe sehr, dass mir jemand helfen kann,
Liebe Grüße, JuuriiK :)

msg= Input eines users

blacklist= Blacklist txt datei

Im folgenden ist der Code:

using System;
using System.IO;
using System.Linq;


public class CPHInline
{
    public bool Execute()
    {
        string userName = args["userName"].ToString();
		string TOSmsg = args["TOSmsg"].ToString();
        string msg = args["rawInput"].ToString();
        string[] blacklist = File.ReadAllLines(args["blacklistDatei"].ToString());
		string actionName =  args["actionName"].ToString();
        if (blacklist.Equals(msg))
        {
            CPH.TimeoutUser(args["user"].ToString(), 30);
            CPH.SendMessage(TOSmsg);
        }
        else
        {
            CPH.RunAction(actionName);
        }


        return true;
    }
}
Computer, Vergleich, Programmierer, programmieren, C Sharp, Programmiersprache, String
Wie kann ich meinen Python-Code schneller machen?

Hallo,

ich habe gestern in Python ein paar Funktionen geschrieben, die mir ein interessantes Bild ausrechnen sollen. Ich kriege es jedoch nicht hin, dass das Programm einigermaßen schnell läuft und am Ende muss auch die Auflösung darunter leiden

Wenn da mal jemand drüberschauen könnte, wäre das wirklich hilfreich.

import numpy as np
import matplotlib.pyplot as plt
from math import pi, sqrt, atan

#Punkt definieren
class point:
    def __init__(self,x=0,y=0,z=0):
        self.x = x
        self.y = y

    #Operationen
    def __str__(self):
        return "({0},{1})".format(self.x, self.y)

    def __add__(self, other):
        return point(self.x+other.x,self.y+other.y)

    def __sub__(self, other):
        return point(self.x - other.x, self.y - other.y)

    def __abs__(self):
        return sqrt(self.x**2 + self.y**2)

    def __mul__(self, other):
        if type(other) == point:
            return point(self.x * other.x, self.y * other.y)
        return point(self.x * other, self.y * other)

    def __truediv__(self, other):
        if type(other) == point:
            return point(self.x / other.x, self.y / other.y)
        return point(self.x / other, self.y / other)

    def __neg__(self):
        return point(-self.x,-self.y)

# weitere Funktionen für Punkte
def dis(PointA,PointB):
    return abs(PointB-PointA)

def dir(PointA,PointB):
    return (PointB-PointA)/dis(PointA,PointB)


#Funktion für den Wert
def grav_v(x,y,time=5,frames=60):
    p = point(-1,0)
    sp = point(x+1,y)

    c = point(0,0)
    sc = point(0,0)
    
    #Vielleicht wegen des for-loops so langsam?
    for k in range(frames*time):
        try:
            plus = dir(p,c) * 1/dis(p,c)**2 / frames
            sp += plus
            p += sp/frames
            sc -= plus
            c += sc/frames
        except:
            pass

    return p


#Funktion für das Bild
def grav_c(a=-4, b=4, smoothness=1):
    ROWS = []
    p = 0
    print(0)
    #zwei for-loops...
    for Y in np.linspace(a,b,int(200*smoothness)):
        row = []
        for X in np.linspace(a,b,int(200*smoothness)):
            g = grav_v(X, Y)
            row.append( (abs(atan(g.x)*2/pi), abs(atan(g.y)*2/pi), abs(atan(abs(g))*2/pi)) )
        ROWS.append(row)
        p += 1
        print(p / (200 * smoothness))
    plt.imshow(ROWS, extent=(a, b, a, b))
    plt.show()

grav_c()
Computer, Programm, programmieren, Effizienz, Informatik, Programmiersprache, Python

Meistgelesene Beiträge zum Thema Programmiersprache