C# if statement within a range [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need my if statement to return an image if it is within a range. the current code does not work
if (Int32.Parse(Domain_OSUMC_IT_CHECKBOX.Text.Trim()) == 1)
{
Domain_green_Check.Visible = true;
}
else if (Int32.Parse(XP_OSUWMC_IT_LBL.Text.Trim()) >= 1 && <=.9)
{
Domain_green_Check.Visible = true;
This is where im having the trouble
else if (Int32.Parse(XP_OSUWMC_IT_LBL.Text.Trim()) >= 1 && <=.9)
I need to make the image domain_green_check visible if another label Domain_OSUMC_IT_CHCEKBOX is between the values of .9 and 1

You need to fix your syntax and conert the string to decimal
decimal val = decimal.Parse(XP_OSUWMC_IT_LBL.Text.Trim());
else if (val > .9 && val < 1) //though this condition makes nosense since it will never evaluate to TRUE

Related

How to loop this properly [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 months ago.
Improve this question
I have tried looping this it didnt work for me please help me im trying to learn c# and it would help alot if you would help me
using System.Text.RegularExpressions;
{
Console.WriteLine("What do you want to check, if its a number or not: ");
int myInt = Convert.ToInt32(Console.ReadLine());
bool isLessThan10000000000 = myInt < 10000000000;
Console.WriteLine("Is it a Number? {0}", isLessThan10000000000);
Console.ReadKey();
Console.WriteLine("Do you want to continue (Y/N)? ");
if (Console.ReadKey().KeyChar == 'Y')
{
}
else
{
}
}
You can use a do while loop
it's about the same as a while loop expect it evaluates the condition after the loop instead of before
do
{
//Your code
}
while(Console.ReadKey().KeyChar == 'Y');

How to verify if 3 different string List´s in c# console app have the excactly same size of entries [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
Hello i have this code here.
List<string> list = BarCode.Split(';').ToList();
List<string> list2 = OBS.Split(';').ToList();
List<string> list3 = OBS2.Split(';').ToList();
I want to verify in a if statment if they have the same size of entries.
How can i do that?
This is what i ended up doing
int sizeList1 = list.Count;
int sizeList2 = list2.Count;
int sizeList3 = list3.Count;
if (sizeList1 == sizeList2 && sizeList1 == sizeList3)
{
}
With LINQ you can use All, it's readable even with many lists:
bool sameSize = new[]{list2, list3}.All(l => l.Count == list.Count);
With an if:
if(list.Count == list2.Count && list.Count == list3.Count)
{
}
You can just compare its counts.
bool isSameSize = list.Count == list2.Count && list2.Count == list3.Count;

Transform alpha-numeric strings to int value [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am looking for a way to transform strings of any size to an integer.
For example: "a" - 01; "b" - 02; "c" - 03; "ab" - 0102; "aac" - 010103.
Right now, I am replacing every single char in the string with a value from an array.
Is there a simple, more fancy way to do this?
more fancy
string source = "aac";
string result_string = string.Join("", source.Select(c => (c - 'a' + 1).ToString("00")));
string source = "aac";
int result_int = source.Select(c => (c - 'a' + 1)).Aggregate((a, i) => a * 100 + i);

How To Skip Message From SupreGroup or channel to Bot by c#? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
i want to skip updates from supergroup or channel by c#
used telegram-bot 11.3 .
foreach (var update in updates)
{
offset = update.Id + 1;
if (update.Message.Chat.Type.GetType().ToString() != "Supergroup" || update.Message.Chat.Type.ToString() != "Channel")
//if (update.Message.Chat.Type.ToString() != Supergroup || update.Message.Chat.Type.ToString() != "Channel")
{

how to achieve for loop IronPython [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How to achieve this C# for-loop in IronPython, I can't seem to find a way to make i - 10 in IronPython
int amount = 32;
int scrolls = 0;
int mets = 0;
if (amount >= 10) {
for (int i = amount; i >= 10; i -= 10) {
scrolls++;
if (i - 10 < 10)
mets = i - 10;
}
}
Your loop exit condition is i >= 10. Your loop entry condition is amount >= 10. i gets set to your amount on loop entry, which is already >= 10. Your loop will never execute.

Categories

Resources