It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need to go through two arraylists (for the ones answering my previous question, I've solved it), one ("dir") has text saved on it which will be used as an Instruction, and the other one ("time") has numbers in it wich will be used for the Interval of a Timer ("Timer.Interval"). What I need to do is to make each position of "Dir" be done continiously until the timer ticks (Timer.Tick), then go to the next position.
This is as far as I got:
int i = 0;
for ( i = 0; i > -1; i++)
{
Console.WriteLine(cls.dir[i]);
Console.WriteLine(cls.time[i]);
if (cls.dir[i] == "one")
{
timerSeconds.Interval = Convert.ToInt32(cls.time[i]) * 1000;
Label1.Text = "Hello StackOverflow";
}
}
In this case to make it more easy to understand I made and example, what it's supposed to do is to show a different text as a sign in the Label1 as long as the time Arraylist says for each block. I know this is incomplete, how would you end it?
It sounds like you want to "wait" a certain number of milliseconds.
If so, the best way to do this is with a "Sleep":
if (cls.dir[i] == "one")
{
int interval = Convert.ToInt32(cls.time[i]) * 1000;
Label1.Text = "Hello StackOverflow";
System.Threading.Thread.Sleep(interval);
}
Label1.Text = "Time to wake up";
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
It has soon been 12h of trying this and I can't get it to work. I have read all the threads I can find and nothing helps. I have tried to fiddle around with Excel Wrapper as well but it doesn't work. I'm new to C# and I'm trying to do a bullshit generator. What I am trying to do is reading a bunch of words from A1-A5, B1-B5 and C1-C5 in an .xlsx-file and putting them together in a textbox (I'm using Visual Studio) when clicking a button.
If anyone reads this and could give me a hint it would be much appreciated. Thanks in advance.
First you should pull the info from the xls doc to a collection (array, list, etc...)
The code for this should be easy to find online.
You are also going to need a random number generator:
Random rnd = new Random();
Then you are going to have the button click event select 2 random numbers, one for row and one for column, from your collection (2D array in this case):
int row_max = stuff[][].GetLength(0);
int col_max = stuff[][].GetLength(1);
int row = rnd.Next(0, row_max-1)
int col = rnd.Next(0, col_max-1); //between 0 and the number of columns
textbox1.text = textbox1.text + stuff[row][col].ToString();
This is indicative only, but all the parts of this can be easily googled.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have php code that puts some values into an Array as follows:
$hunter=addslashes($MessageArray[1]);
$time=addslashes($MessageArray[2]);
I wrote the same code in C# and wanted to know if it was correct.
string Hunter = Messagearray[1].tostring();
string time = Messagearray[2].tostring();
As James mentioned, use Pascal casing:
string hunter = messageArray[1].ToString();
string time = messageArray[2].ToString();
Also, C# arrays are indexed starting at 0. You can change the starting index of arrays in PHP, but you can't in C#. Perhaps you do wish to take the 2nd and 3rd items, but keep it in mind. You might want:
string hunter = messageArray[0].ToString();
string time = messageArray[1].ToString();
As far as addslashes() goes, it will depend on your usage of hunter and time. If you're using them in a SQL statement, there are other ways of accomplishing the functionality of PHP's addslashes().
Snipped from Here
public static string AddSlashes(string input)
{
return System.Text.RegularExpressions.Regex.Replace(input, #"(\\)([\000\010\011\012\015\032\042\047\134\140])", "$2");
}
Usage:
//
var Messagearray = new object[] { "item 0", 1 };
var hunter = AddSlashes(Messagearray[0].ToString());
var time = AddSlashes(Messagearray[1].ToString());
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
try
{
for (int i = 0; i <10; i++)
{
DoStuff();
if (i>3 && 1== i% 2)
{
throw new Exception();
}
}
}
catch (Exception ex)
{
DoOtherStuff();
}
DOSTUFF() is called 0 times because C# method names are case-sensitive.
If you really meant DoStuff(), then assuming it is not an unimplemented partial method and the method itself is not marked with a conditional attribute specifying an undefined symbol, then it will be called 6 times as in #MikeCito's answer.
6 times. When i hits 5 the remainder will be 1 and it will be greater than 3.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Continuing from my previous question, I now want to remove the number once I have found it and stored it in a variable.
Just a slight tweak to my response to your first question to instead use Regex.Replace method will git 'er done.
Don't worry I figured it out. Just need to find the length then delete the chars
(qual is the intergers found)
string length = qual.ToString();
int length2 = length.Length;
text.Remove(0, length2);
I think the following code resolves the root problem:
string originalString = "35|http://www.google.com|123";
string[] elements = originalString.Split(new char[] { '|' }, 2);
int theNumber = int.Parse(elements[0]); // 35
string theUrl = elements[1]; // http://www.google.com|123
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I cant seem to figure out what is wrong with my check digit code!
At times, it produces 2 length check digit values
Example
1277531815000110 <-- check digit is double value??????
1277532495000110 <-- check digit is double value???????
1277534649000110 <-- check digit is double value???????
127753185300011 <-- good!
127753208500019 <-- good!
All generated numbers are valid, it can be checked at http://www.ee.unb.ca/cgi-bin/tervo/luhn.pl?N=127753224800013
CODE: http://dl.dropbox.com/u/678582/Email/GenerateAN.txt
This line's the problem:
CheckSumNumber = (((sum / 10) + 1) * 10) - sum;
That will generate 10 when sum is already a multiple of 10. Basically you're just trying to round up. Here's an easy way of doing it:
CheckSumNumber = (((sum + 9) / 10) * 10) - sum;