|
Did you add a reference to the DLL by opening the Solution Explorer, context-clicking on References, selecting Add References from the drop-down, and browsing to find the DLL ?
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
Why someone down voted your question I do not know, it shows a lack of knowledge rather than blind stupidity. However the knowledge should not be gathered just from forums, get a book/tutorials and work through the examples.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I followed your advices and now it works
Thanks to everyone
|
|
|
|
|
I have a decstop application in c# and i want to run on diffrent client machine in diffrent cities . which type of services i have to use
please suggest me ....
Er. vipin gupta
|
|
|
|
|
If you're talking about a "desktop" application, we have no idea what it does, what it's requirements are, what kind of communication it requires and with what type of services, or anything else about your app.
Basically, your question, as asked, is impossible to answer!
|
|
|
|
|
Recently, i saw a person who was not changing the question and answer a bit but using improve solution to get points.
1) So please check if the matter before and the new matter is not exact.
2) Please make it compulsory for everyone to write in "What have you changed".
|
|
|
|
|
Please don't post questions like this in the technical forums.
Veni, vidi, abiit domum
|
|
|
|
|
Wrong forum. And there's no clear(& complete) details in your message. Include the link which are you talking about
Post your detailed message there[^] or there[^]
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
sorry sir i will post it in the link you provided
|
|
|
|
|
I have two tables, call it part and customer.
Part
PartId PartDesc
1 Bolt
2 Screw
3 Nut
Customer
CustomerId PartId
1 1
2 1
3 1
1 2
I want a result that looks like this:
PartId CustomerId
1 1, 2, 3
Sorry for the rough example, but how do I flatten multiple records like that into a comma separated list?
Thanks for any guidance, cheers, --EA
|
|
|
|
|
Try:
SELECT PartId, CustomerIds=
STUFF((SELECT ',' + CONVERT(VarChar(10), CustomerId)
FROM Customer b
WHERE b.PartId = a.PartId
FOR XML PATH('')), 1, 1, '')
FROM Customer a
GROUP BY PartId
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
I called this LINQ Query grouping in the title but probably should have specified this is a LINQ to Entities query. I think I have it figured out now, thank you though.
Cheers, --EA
|
|
|
|
|
Hi,
i'm currently developing an application that uses tamir sharp ssh for file transfer
http://www.tamirgal.com/blog/page/SharpSSH.aspx[^].
I created a datalayer, that references the tamir sharp ssh dll (version 1.1.13).
I'm using the asynchronous method
scp.From(sourceFileName, destFileName);
to receive a file from a remote server.
and i have also registered an appropriate event callback
scp_OnEnd(string sourceFile, string destinationFile, int transferredBytes, int totalBytes, string message)
this callback is triggered after a transfer was completed by the scp.From method.
The methods scp.From(..) works fine, for file sizes like 1MB. If i use files larger than 10MB than, the file is not transferred completely. Actually it's a zip file, and 99% of the file is transferred, only a few bytes are always missing. Mostly i'm missing between 1k and 3k bytes - depending on the total file size. If i try to open the file with a zip-tool it complains about an unexpected end of the archive.
does anyone have experienced a similar behavior?
Does anyone have an idea what could cause this issue?
Is there maybe a free alternative to this c# library?
Thanks,
Regards,
Michael
|
|
|
|
|
Michael Gaida wrote: The methods scp.From(..) works fine, for file sizes like 1MB. Alternatively, you could divide your 10MB blob into 10 chunks of a MB each.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Alternatively, you could divide your 10MB blob into 10 chunks of a MB each.
Hi Thanks for this input. I also thought about that, but this would mean, that i will have to implement a bit more business logic.
I solved this issue with by replacing the sharp ssh by renci ssh. I just had to rename some objects and their contained method. I also had to implement three new events contained in the renci ssh dll. But in summary i think this is way more easier and stable, than this workaround idea .
If anyone faces a similar issue, i can recommend to change from tamir sharp ssh, to renci ssh .
https://sshnet.codeplex.com/[^]
Thanks,
Regards,
Michael
|
|
|
|
|
I have tried to write a program that takes in an array size, fills an array with random elements with each element being used only once. Elements must also be greater than 1 but below the array size. However, when I set the array size as 5, the console only shows me 4 elements!
This happens with all sizes entered, it always shows me 1 element too few! The shuffling is working correctly, however. Can anyone tell me how I can get it to display as many elements as the array size is set to?
Example, if the user enters 5 as the array size, the console should enter 5 random numbers (2,3,5,6,1), but instead enters 4(5,1,2,3)
private void RunQuestionTwo()
{
int arraySize;
int[] a;
Console.WriteLine("\nTask 2 \nPlease enter an integer to determine the size of the random array\n");
arraySize = Convert.ToInt16(Console.ReadLine());
a = new int[arraySize];
Console.WriteLine("\nThe array will now be displayed\n");
for (int i = 0; i < a.Length; i++)
{
a[i] = i + 1;
}
Shuffle(a);
}
public void Shuffle(int[] a)
{
Random rndNumber = new Random();
int n = a.Length();
while (n > 1)
{
n--;
int i = rndNumber.Next(1, n);
int temp = a[i];
a[i] = a[n];
a[n] = temp;
Console.WriteLine(a[n]);
}
}
|
|
|
|
|
Your Shuffle-loop is incorrect; it starts at (n-1), where n=count. Meaning it will skip one!
Try something like below;
class Program
{
static void Main(string[] args)
{
RunQuestionTwo();
Console.ReadKey();
}
private static void RunQuestionTwo()
{
int arraySize;
int[] a;
Console.WriteLine("\nTask 2 \nPlease enter an integer to determine the size of the random array\n");
arraySize = Convert.ToInt16(Console.ReadLine());
a = new int[arraySize];
Console.WriteLine("\nThe array will now be displayed\n");
for (int i = 0; i < a.Length; i++)
{
a[i] = i + 1;
}
Shuffle(a);
}
public static void Shuffle(int[] a)
{
Random rndNumber = new Random();
int n = a.Length;
Console.WriteLine(string.Format("n = {0}", n));
for (int r = 0; r < n; r++)
{
int i = rndNumber.Next(1, n);
int temp = a[i];
a[i] = a[r];
a[r] = temp;
Console.WriteLine(a[r]);
}
}
} You'd also like to verify the users' input and prevent the app from blowing up on 'unexpected' input. I made the methods static, since that's preferred for methods that don't change (local object) state.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks very much! It worked Also thanks to all others who helped 
|
|
|
|
|
Try:
public void Shuffle(int[] a)
{
Random rndNumber = new Random();
int n = a.Length - 1;
while (n > -1)
{
int i = rndNumber.Next(0, n);
int temp = a[i];
a[i] = a[n];
a[n] = temp;
Console.WriteLine(a[n]);
n--;
}
} Test in some method:
int[] a = new int[5] { 1, 2, 3, 4, 5 };
for (int i = 0; i < 10; i++)
{
Shuffle(a);
Console.WriteLine();
} I'm not sure to what degree your shuffle method may provide "randomness," but, many folks question the inherent randomness of the .NET Random function itself. I suspect your shuffle is fine for general purpose use.
For a really advanced solution to this using Linq, with an interesting discussion of bringing GUID's into play to increase randomness: [^].
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
modified 16-Jan-14 10:33am.
|
|
|
|
|
I think that article is a bit wrong:
Quote: Every number will be the first in the sequence based on the supplied seed. If you call it twice with the same seed (i.e. within one tick) you will get the same number.
Random.Next() should return the next number in the pseudo-random sequence every time is called. You cannot 'call it with the same seed' (you have to creata a new instance of the Random class and it is usually done only by mistake).
Moreover, I don't buy the GUID argument as a general improvement because, while the Random.Next() provide you a pseudo-random sequence following a uniform distribution, I don't know the distribution System.Guid.newGuid() follows.
Veni, vidi, vici.
|
|
|
|
|
Just to add to what Bill and Eddy say, you should not declare the Random instance within the Shuffle method: it is initialized from the system clock when it is created, so if you call Shuffle twice in quick sucession, you could get the same random sequence.
Instead, declare it as a private class level variable and reuse the same instance each time Shuffle is called:
private static Random rndNumber = new Random();
public static void Shuffle(int[] a)
{
int n = a.Length;
...
There is another detail: did you notice that the first element is never shuffled? That's because your Random.Next call can't return zero...
BTW: Length is a property of an array - you don't need to treat it as a method! (And the compiler will complain if you do)
If you don't mind my saying, that isn't quite the way I'd do it. I don't know how much you know yet, but I wouldn't do an in-place shuffle. I'd would arrange that the Shuffle method returned a new set of values rather than reorganising the original, and I'd probably make it generic. Heck, does this make any sense to you?
int[] a = new int[arraySize];
for (int i = 0; i < a.Length; i++)
{
a[i] = i + 1;
}
int[] b = Shuffle(a).ToArray();
Console.WriteLine("\nThe array will now be displayed\n");
foreach (int i in b)
{
Console.WriteLine(i);
}
}
private static Random rndNumber = new Random();
public static IEnumerable<T> Shuffle<T>(IEnumerable<T> a)
{
int values = a.Count();
List<T> output = new List<T>(values);
List<T> input = a.ToList();
for (int index = 0; index < values; index++)
{
int i = rndNumber.Next(0, input.Count());
output.Add(input[i]);
input.RemoveAt(i);
}
return output;
}
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
Really satisfying to see some back-and-forth here, and a variety of solutions !OriginalGriff wrote: your Random.Next call can't return zero I beg to differ: the 'Next method of the Random Class can, indeed return it's first minValue argument:
"minValue Type: System.Int32 The inclusive lower bound of the random number returned." Oh ... wait ... I see ... ... my bad ... you are referring only to Eddie's code.
I agree with you that initializing the Array in advance is a waste of time. If I were going to "shuffle," I'd probably use the technique shown in the article I cited.OriginalGriff wrote: does this make any sense to you? Everything you say makes sense to me ... dammit
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
I meant the OPs original code, but yes, Eddies code also has a minValue of one.
I agree, this was a better format for questions because it encouraged discussion and improvements, which I don't feel QA does: it seems to "compartmentalise" answers so there is less cross fertilisation between answers.
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
Two more candidates for the beauty contest:
Candidate One:
private Random newRandom = new Random();
private List<int> MakeShuffledList1(int nItems)
{
return Enumerable.Range(1, nItems).ToList().OrderBy(item => newRandom.Next()).ToList();
}
List<int> newList = MakeShuffledList1(10);
Candidate Two:
private Random newRandom = new Random();
private List<int> MakeShuffledList2(int nItems)
{
List<int> shuffleList = Enumerable.Range(1, nItems).ToList();
List<int> resultList = new List<int>();
int currentValue;
while (shuffleList.Count > 0)
{
currentValue = shuffleList[newRandom.Next(0, shuffleList.Count - 1)];
resultList.Add(currentValue);
shuffleList.Remove(currentValue);
}
return resultList;
} This follows the usual beauty pageant drill: when Miss/Mr. Whatever is crowned, you know he/she will not be in the next selection category.
Test:
List<List<int>> bunchOLists = new List<List<int>>();
for (int i = 0; i < 10; i++)
{
bunchOLists.Add(MakeShuffledList1(5));
bunchOLists.Add(MakeShuffledList2(5));
}
bool IsDuplicate = false;
List<int> currentList;
for (int i = 0; i < bunchOLists.Count - 1; i++)
{
currentList = bunchOLists[i];
for (int j = 0; j < bunchOLists.Count - 1; j++)
{
if(i != j)
{
IsDuplicate = currentList.SequenceEqual(bunchOLists[j]);
}
}
}
Console.WriteLine("all List<int> are unique: " + (! IsDuplicate).ToString());
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
modified 17-Jan-14 2:13am.
|
|
|
|
|
Message Closed
modified 17-Jan-14 4:52am.
|
|
|
|
|