|
If it's that simple, it usually is homework.
|
|
|
|
|
Dave Kreskowiak wrote: If it's that simple, it usually is homework.
I wish mine had been! I might have handed it in more often...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Generate your first random number, change your random seed, generate another number and multiply both of them.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
@ Abhinav
You shouldn't change seed. If you change the seed, you are affecting the random number generation.
In fact, try this:
for (int i = 0; i < 100; i++)
{
Random rnd = new Random();
Console.WriteLine(rnd.Next());
}
You will see that when you change the seed, the same number will be generated multiple times.
Random rnd = new Random();
for (int i = 0; i < 100; i++)
{
Console.WriteLine(rnd.Next());
}
This however will generate different number every time.
|
|
|
|
|
If you use the same seed, you will get an identical list of numbers.
See here and here.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
You would get identical lists if you use the same seed in two instances of random, but you're not going to use two instances of random anyway because that's the recipe for failure.
|
|
|
|
|
Ah...I see what you mean...you are right, we need only one Random instance anyway.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Yes sir. You are right here. But if you change the seed automatically using Random rnd = new Random(); the seed is going to be the same if there is no delay in time. Check with the code sample I provided.
However, you do not need to change the seed. Next method always returns a new random number.
Usually when you need to generate multiple Random Numbers, stick to the same Random Object with the seed used for the first time.
|
|
|
|
|
Yup got it.
Thanks
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi,
My ConnexionForm contains 2 fields Login and Password.The user types his parameters.The system must verify the existance of this user in its database .sdf.So,I am blocked in relating my database with my interface.
First,Iwanna ask if ADO.NET is installed by default with Visual Studio 2008 or should i install it.
Second,this is my ConnexionForm's code that i haven't got any result with it:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.Configuration;
using System.Text.RegularExpressions;
namespace PFE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
MenuPrincipal f = new MenuPrincipal();
f.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
String connectionString = null;
try
{
connectionString = ConfigurationManager.ConnectionStrings["boutique"].ConnectionString;
}
catch (Exception e1)
{
Console.WriteLine("Erreur de configuration : {0}", e1.Message);
return;
}
Console.WriteLine("Chaîne de connexion à la base : [{0}]\n", connectionString);
try
{
using (SqlCeConnection connexion = new SqlCeConnection(connectionString))
{
connexion.Open();
MessageBox.Show("success");
}
}
catch (Exception ex)
{
Console.WriteLine("Erreur d'accès à la base de données (" + ex.Message + ")");
}
}
}
}
Thanks a lot for u contribution
|
|
|
|
|
right usually when i read Xml I do it like this :
XmlDocument XmlDoc = new XmloDocument();
XmlDoc.Load("C:\\Example.xml");
XmlNodeList XmlnodeyList = XmlDoc.SelectNodes("Xml/Node");
foreach(XmlNode Nodey in XmlNodeyList)
{
listView1.Items.Add((string.format("{0}", Nodey.Attributes["ExampleNode"].Value.ToString())));
}
Now that then populates a listview with the nodes in the xml file, I now have been pulling my hair out trying get it to red the second area of the nodes for example in the xml file :
<Node ExampleNode='Meh' SecondNode='Example' /> Sorry CodeProject Wouldent display it properally :)
i want it to read the SecondNode but since i have say 4 of them all diffrent i want it to then read it and make a label have the secondnode text from the listview selected item , Here is the code i wrote for it :
string Name = listView1.SelectedItems[0].ToString();
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.Load(XmlPath);
XmlNode Nodey = XmlDoc.SelectSingleNode(string.Format("Xml/Node/{0}", Name));
label1.Text = (string.Format("{0}", Nodey.Attributes["SecondNode"].Value.ToString()));
so on click from the listview it gets the second node etc ,
any help wouyld be grand guys !
Jed
modified on Saturday, April 3, 2010 5:11 AM
|
|
|
|
|
Hi guys,
I want to the validate the user typed credentials such as(username and password) on a windows form against the loged in user. I found the class PrincipalContext which has ValidateCredentials method that takes username and password but it is in framework 3.5. Is there any equivalant methods for framework2.0
Thanks
|
|
|
|
|
On what version of Windows did you install the AD?
Have you tried the empty username/credentialset? It should try to validate the default-principle if the login-information is omitted;
If no credential were specified in the constructor, and the username and password parameters are null, this method validates the default credentials for the current principal.
I are Troll
|
|
|
|
|
I have been all over Google to figure out a way to download a file from YouTube. Well, looking for the code.
I have no clue how its done.
Well, I visited many sites that provided the code (Just Google "Open Source YouTube Downloader" and "C# Download YouTUbe Video".) However, the code I got from them did not download the file. Looked like some string they were looking for was not found on the page.
I also came across an article which stated that YouTube is trying to stop the downloading of videos on other websites and software.
Well, how are some software (commercial) still able to download the video?
If you can help me out, that would be really nice. I am just looking to download .flv, nothing fancy.
Thanks,
Harsimran Singh
1) The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson
2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll
3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris
(Computer code: 00001111 - translation: Hello! :P )
REMEMBER:
"Computers are made for us, we are not made for th
|
|
|
|
|
Perhaps you have to pretend to be a browser. I'd use Fiddler2 to inspect the traffic that goes back and forth between your browser and the YouTube servers when you watch a video. Try to mimic that traffic with your code. If they've built a custom flash control to play the video, that may use some proprietary technique to validate it is being played in their player, which could complicate things. Perhaps the commercial software (Flash?) just captures the resulting video (i.e., that gets played back on the screen) rather than the data sent over the internet. Sorry I can't provide you with a specific solution (only general guidance)... you may need to do some more work to figure this out yourself.
|
|
|
|
|
You are right. YouTube really has complicated things. Some software I downloaded to download files from YouTube, didn't work either.
There might be another way which I just came across. I am using the YouTube Data API, and when I was debugging (hoping to find some clue to the download link), I came across another link, that was a rstp protocol link. I was wondering if there is a way to download a file from that protocol. But I couldn't find anything on Google either.
Sorry, I am not that good with web and desktop combined.
Thanks,
Harsimran Singh
1) The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson
2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll
3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris
(Computer code: 00001111 - translation: Hello! :P )
REMEMBER:
"Computers are made for us, we are not made for th
|
|
|
|
|
I think you are right. After checking with Fiddler, there is a GET method, which sends YouTube the url of the video. The url is pretty complicated and looks like it works on Ip address.
Well, how can I intercept the JSON response from YouTube to the browser with a C# desktop application? I have no clue how to do this. I came across this: http://stackoverflow.com/questions/2077265/json-in-c-sending-and-receiving-data[^], but that wasn't helpful either.
Can you please help me??
Thank you very much,
Harsimran Singh
1) The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson
2) Why is it drug addicts and computer afficionados are both called users? - Clifford Stoll
3) The real danger is not that computers will begin to think like men, but that men will begin to think like computers. - Sydney J. Harris
(Computer code: 00001111 - translation: Hello! :P )
REMEMBER:
"Computers are made for us, we are not made for th
|
|
|
|
|
could someone help me change the sound card (if installed more than one) using winmm.dll? I can not use the DirectSound API, for does not support mp3 files. Please someone help me!
|
|
|
|
|
I've never used it for audio, only MIDI which is in the same dll so I assume the principal is the same.
You use the xxxGetNumDevs function to get the number of devices installed. Each of these devices are assigned an ID from 0 to numDevs - 1.
You can call xxxGetDevCaps to get the name and other capabilities of the In or Out device using the ID.
To use the device you call xxxOpen using the ID which will give you an IntPtr which you use to identify the device for all other functions, and you specify a delegate in this function too which will be called for all events of the device (hint: watch out as callbacks may be on a different threads for different events!).
You will need to look in MMSystem.h and this MSDN page[^] to figure out all your P/Invoke signatures and structures.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hello,
I must add the Ctrl+Z character to string at the end for my C# program to work properly.
Here is the hypotetic code:
char ctrl_z= 'what to type';
string the_string = "Text which ends with ctrl+z character" + ctrl_z;
or
string ctrl_z= "what to type";
string the_string = "Text which ends with ctrl+z character" + ctrl_z;
What to type for char and string declaration of ctrl_z , respectively.
SPIRANCA
|
|
|
|
|
char ctrl_z = (char) 26; /ravi
|
|
|
|
|
Someone 1-voted that; I have no idea why...
P.S. Maybe they wanted Unicode char ctrl_z = '\u0026' ;
|
|
|
|
|
Which is why I pay no attention to ratings like "Reputation". I try to help people (when I'm able to) because others have helped me.
/ravi
|
|
|
|
|
Well said.
It is a shame it is only possible to measure the irrelevant, such as up-votes/down-votes, and number of posts. Only by seeing how helpful someone is could you give a proper rating.
|
|
|
|
|
sometimes it is relevant for future use to reader.
Life's Like a mirror. Smile at it & it smiles back at you.- P Pilgrim
So Smile Please
|
|
|
|