C
C#Jin

String Contain issue

So im trying to get a word in a string using Contain but its not getting the word, I havent found a workaround it or im just completely doing it wrong.
if (OtherUser != null)
{
string bio = OtherUser.Bio.Replace("\n","").Replace(" ","").Trim();
if (bio.Contains("OwlHouse#disc"))
{
await RespondAsync($"{Context.User.Mention} You have been verified.",ephemeral: true);
}
else
{
await RespondAsync($"{Context.User.Mention} You do not have the code in your Bio. \n`[ BIO ]` \n{bio}", ephemeral: true);
}
}
if (OtherUser != null)
{
string bio = OtherUser.Bio.Replace("\n","").Replace(" ","").Trim();
if (bio.Contains("OwlHouse#disc"))
{
await RespondAsync($"{Context.User.Mention} You have been verified.",ephemeral: true);
}
else
{
await RespondAsync($"{Context.User.Mention} You do not have the code in your Bio. \n`[ BIO ]` \n{bio}", ephemeral: true);
}
}
P
Playboi17399d ago
I may be wrong but it looks like there’s a space before and after the “#”
H
Henkypenky399d ago
this is a perfect example to use the debugger place a breakpoint at string bio and see what the actual string is then just use a text editor to search for your desired word because this:
string bio = OtherUser.Bio.Replace("\n","").Replace(" ","").Trim();
string bio = OtherUser.Bio.Replace("\n","").Replace(" ","").Trim();
can produce anything how can we know it will have your desired word in it also, contains will not fail so the problem is in your string output 100%
M
MODiX399d ago
Henkypenky#4865
REPL Result: Success
string bio = "1223312321-5415157*/-456/*/*4651-OwlHouse#disc-DSAE3412DASKIOCASUNUI12312321DASCZXCAWSEDASDSA";
if (bio.Contains("OwlHouse#disc"))
{
Console.WriteLine("Omg, yes it does");
}
string bio = "1223312321-5415157*/-456/*/*4651-OwlHouse#disc-DSAE3412DASKIOCASUNUI12312321DASCZXCAWSEDASDSA";
if (bio.Contains("OwlHouse#disc"))
{
Console.WriteLine("Omg, yes it does");
}
Console Output
Omg, yes it does
Omg, yes it does
Compile: 612.350ms | Execution: 35.149ms | React with ❌ to remove this embed.
J
Jin399d ago
because it replied back the string in the screenshot. actually i think this might be the issue. yeah that was the issue.
Want results from more Discord servers?
Add your server
More Posts
❔ Catching Exceptions with generic parameters?When adding an entity to the database, i first check if it already exists and if it does I throw an ❔ How should I learn programming?I'm sure this is a common question, but I want to learn game development but am a pretty new C# prog❔ How to properly structure projects in a multi-app MVVM solution?I tend to structure my MVVM projects in the following way: ``` . ├── src/ │ ├── Applications/ │ Sending File and Data to a Minimal API endpointHi. I am using .NET 7, Minimal API and Mailkit. What I want to do is to send an attachment along wi❔ reprotucing the kings pathcan anybody help me fix this code https://paste.mod.gg/sgsvrbaqnmpi/0 ``` the input is number of obs❔ Its there a way to fix this?Hi there, currently I am trying to develop some functions to publish them to azure later, but right ✅ Does this styling code look right?I'm using this code for a simple hover effect. Im wondering if I'm doing this correctly: <Window.Re❔ ?[] operator for dictionariesIs not working. It is explained here. https://learn.microsoft.com/en-us/dotnet/csharp/language-refer❔ IAsyncEnumerable vs List<T> as parameter in methodI have a method that is overloaded and will take in a List<T> or IAsyncEnumerable. The method will b❔ This code is bugged how can i solve it?```LogiwaEntities1 db = new LogiwaEntities1(); ProductData productData = new ProductData✅ How to add hover effect to WPF button elementThis code I'm using isn't working. When I hover over buttons its a lightblue color. <Style with or without refso i learned that in c#(or most oop languages) when you create a method that takes an object as a pa✅ .net trying to find non-existent cs files`Error IDE1100 Error reading content of source file 'D:\Dev\C++\Test\TestCS\obj\Debug\net6.0\.❔ WPF - Binding to last child of collectionI have the following setup: ```csharp public partial class StatusMessageService : ObservableObject ✅ What does WPF want from me?I'm actually so tired of WPF and MVVM and all this contrived fuckin bs you guys MainWindow control:❔ I apparently have an infinite loop, but I can't fix it to workI've tried a lot of stuff, even a "NewtonJson" fix I saw, but it wouldn't solve the problem because ✅ doing nothingdfg❔ I would appreciate some help.So i have this assignment and in lieu of my grandma who passed this past week i've not had the oppor❔ Discord Bot Service ProblemDoes anyone know how to register that service properly?❔ abstract class vs interface```cs public interface IFoo { protected static string GetFormattedTime() => DateTime