|
|
Excellent!
And you know how to add an event handler, I'm sure?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Open Visual Studio.
Immediately after you set the Interval property, type the name of your Timer instance, followed by ".Tick":
myTimer.Interval = 60 * 1000;
myTimer.Tick Press the Tab key. Intellisense will fill in the rest of the line, and create a Tick event handler for you, containing just a "not implemented" exception for you to replace with your code.
You've done that before, haven't you? It's pretty basic stuff!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
You're welcome!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
how will I take ownership in registry subkey... from other owner(TrustedInstaller) to Administrator's.
|
|
|
|
|
Google for "C# take ownership of registry key" for examples and start reading.
|
|
|
|
|
I have an array of string which is
string[] myarr = new[] { "a", "b", "c" };
Can you please help me how to get this result?
a
ab
abc
I tried this one but I just don't know how to get the value from the array and add it on my list
string[] myarray = new string[] { "a", "b", "c" };
List<string> resultarray = new List<string>();
int i, j;
for (i = 0; i <= myarray.Length; i++)
{
for (j = i; j <= i; j++)
{
}
}
|
|
|
|
|
A simple loop: print the first character, print the first and the second, ...
|
|
|
|
|
Member 13081065 wrote:
for (j = i; j <= i; j++) What values do you think j is going to take within that loop?
Try debugging your code and stepping through the loops. Do the values you see in the debugger match what you were expecting?
NB: You don't need an inner loop at all. String.Join[^] has an overload which lets you specify the range of elements from the array that you want to join. For example:
string[] input = { "0", "1", "2", "3" };
string output = string.Join(string.Empty, input, 0, 3);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You get a value from an array by using an index - a numeric value that ruins from 0 to (N - 1), where N is the number of elements in the array. So valid indexes for your myarr array woudl be 0, 1, and 2.
If you want "a", then you use myarr[0]
If you want "b", then you use myarr[1]
If you want "c", then you use myarr[2]
That index value can be in a variable:
int index = 2;
Console.WriteLine(myarr[index]); Would print "c" for example.
Think about what your tutor wants you do to, and work out how you would do it manually - that may help you work out what your code needs to do!
Give it a try - this isn't complicated!
Hint: you only need one loop!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
string[] myarr = new[] { "a", "b", "c" };
string s = string.Join( "", myarr);
for ( int i = 1; i <= s.length; i++ ) {
Console.Writeline( s.Substring( 0, i ) );
}
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hello, I am working on a project where I have to make connections with a smartwatch (Samsung gear s3) and a Unity application, then use the heart rate data in the Unity app. Any help is appreciated since I am experiencing problems making it work. Thank you in advance! ^^
|
|
|
|
|
|
Well the problem is that I have never worked before with creating connections of such kind and I don't even know where to begin with. I am currently looking for a client that could establish these connections but still do not know how...
|
|
|
|
|
My wallet is empty ... can you put some money in it? I'm having problems filling it.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I suspect that one will make a loud whooshing noise as it flies quickly above him ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm trying to get into their zone ... the twilight zone.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
What is the difference between Show/Hide or Visible/Hidden"? I have some windows I need to keep running in the background. Searching for something yesterday I came accost a comment that said that Show/Hide are obsolete in a Wpf and I should be using the other. I cannot really find a difference except that Visible/Hidden has an event you can tie to the change.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
If this is a WPF question, then it should be asked in the appropriate forum: Silverlight / WPF Discussion Boards[^] - this is a "Generic C#" forum.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I reposted it under the forum you suggested. I almost put it there in the first place but some references showed it was part of C#.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
I have an idea for a program using the picture viewer control. I would like to have a label at the top of the form that says "Choose a photo of the musicians listed below to see a photo."
Then below that I would make four option buttons. And next to each option button put a musician's name.
Then below that on the bottom have two buttons. One buttons says "Show photo." The other button says "Clear image."
Problem is all the Youtube videos I've seen that demonstrate the picture box have you using open file dialog and it looks like you have to manually browse into the folder on your drive to select the photo.
I don't want to do that. I want my program to be automatic. No browsing for a photo. You select an option and then hit the button "Show photo" and the program shows the photo in the viewer.
But I don't know if this is possible so let me know please.
|
|
|
|
|
Yes, it's possible: you do not need to use a OpenFileDialog to access the image, that just provides you with a path to the file.
If you want to load the file from a specific location, then you can just specify that:
byte[] data = File.ReadAllBytes(@"D:\Temp\MyImage.bmp");
MemoryStream ms = new MemoryStream(data);
Image im = Image.FromStream(ms); Or you can load from the application EXE folder:
byte[] data = File.ReadAllBytes(@".\MyImage.bmp");
MemoryStream ms = new MemoryStream(data);
Image im = Image.FromStream(ms); This has disadvantages in that you can't modify the image reliably as the folder is likely to be read only in production.
Or you can add the image as a resource and embed it in your application:
Image im = Properties.Resources.MyImage; And now you can't change the image from run to run of your app at all because it is part of your application EXE file.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks. But I wish I understood what those lines of code mean. The only thing I understand is where you added the path to the image. That makes sense. But byte[] data and File.ReadAllBytes I don't know the why of that.
And I don't know what MemoryStream ms is either.
If you could perhaps explain what these lines do I would appreciate it.
|
|
|
|