|
Yes you are right, there is an issue. I havent noticed this before:
Visual Studio 7.1 does not show Intellisense for properties (it does for methods e.a.),
but Visual Studio 8.0 does !
Luc Pattyn
|
|
|
|
|
public void abcMethod1()
{
string cspurl = @"http://xyz.aspx";
bool expected = true;
bool actual;
actual = @"http://xyz.aspx";
Assert.AreEqual(expected, actual, "");
}
Here actual Value means, what could i assign for actual variable as am getting mismatch error, as i assigned string value to bool variable.
|
|
|
|
|
Why are you testing a string value to a bool?
Don't you mean:
Assert.IsTrue(cspurl==actual, "Check string equality");
|
|
|
|
|
even then am getting an error, "Operator '==' cannot be applied to operands of type 'bool' and 'string'", if i use the
Assert.IsTrue(cspurl==actual,"Check string equality");
|
|
|
|
|
you declared actual as a bool. Declare it as a string.
|
|
|
|
|
public void abcMethod1()
{
string expected = @"http://xyz.aspx";
string actual = ...;
Assert.AreSame(expected, actual);
}
|
|
|
|
|
I probably don't understand this, but from when we can assign string values to bool (which is always true or false) data value type ?!
If you need compare two strings (use string's .Equals function) :
string ww1 = @"http://xyz.aspx";
string ww2 = @"http://xyz.aspx";
if (ww1.Equals(ww2))
{
// oh yes
}
VirtualVoid.NET
|
|
|
|
|
I have 2 List<string> objects A and B.
I would like to compare A against B and get the following information:
Which elements are only contained in A?
Which elements are only contained in B?
Is there a standard algorithm for this?
Thanks,
Kathy.
|
|
|
|
|
One way is to first sort the lists, then you can easily loop through them side by side and compare them.
Pseudo code:
sort A
sort B
loop {
get a from A
get b from B
if a < b
"Only in A: " + a
advance A
else if b < a
"Only in B: " + b
advance B
else
advance A
advance B
}
You have to keep track of when the lists end, also. I did not include that in the pseudo code, for simplicity.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks.
I should also mention that the lists could be different lengths.
Kathy.
|
|
|
|
|
KatNel wrote: I should also mention that the lists could be different lengths.
I took for granted that they could be, as you want the items that are present in only one of the lists.
---
single minded; short sighted; long gone;
|
|
|
|
|
here's my final:
private void diff2()
{
List<string> aList = new List<string>();
aList.Add("a");
aList.Add("d");
List<string> bList = new List<string>();
bList.Add("z");
bList.Add("a");
CompareLists(aList, bList,
delegate(string a) { Console.WriteLine(a + " only in list a"); },
delegate(string b) { Console.WriteLine(b + " only in list b"); },
delegate(string c) { Console.WriteLine(c + " in both"); }
);
}
delegate void InList(string inputValue);
private void CompareLists(List<string> al, List<string> bl, InList onlyA, InList onlyB, InList both)
{
int a = 0;
int b = 0;
al.Sort();
bl.Sort();
while ((a < al.Count) && (b < bl.Count))
{
int cp = al[a].CompareTo(bl[b]);
if (cp < 0)
onlyA(al[a++]);
else if (cp > 0)
onlyB(bl[b++]);
else
{
++a;
both(bl[b++]);
}
}
while (a < al.Count)
onlyA(al[a++]);
while (b < bl.Count)
onlyB(bl[b++]);
}
|
|
|
|
|
Below a quite different approach in pseudocode:
Collection common=new Collection();
foreach(object i in a.Clone()) {
if (b.Contains(i)) {
a.Remove(i);
b.Remove(i);
common.Add(i);
}
}
At the end, you have three collections: common holds the common items,
a and b only keep the non-common items.
a.Clone is necessary since we want to modify a while enumerating.
Luc Pattyn
|
|
|
|
|
I was trying to schedule the computer to go into standby / hibernate mode. After a specified duration I wanted the PC to come out of standby. I wanted to automatically send my computer to standby between specific times of the day.
Its easy enough to send the computer into standby, how do you bring it out?
Does anyone know how to accomplish this?
Thanks in advance.
|
|
|
|
|
I would like to know how can i move with IEnumerator movenext and moveback, that is forward and back in the list iterated.
|
|
|
|
|
IEnumerator only supports moving in a logically forward direction. Further, the Reset() method is optional and may not be supported by all instances of IEnumerator .
/ravi
|
|
|
|
|
Hey
Does anyone have an idea to implent something like paint? I need to create a program like Pictionary or iSketch.net but I have no idea to implement the drawing area.
Greetings
K.
|
|
|
|
|
|
Perhaps the Scribble[^] sample will help you get started?
/ravi
|
|
|
|
|
Thanks guys, I'll look into that.
|
|
|
|
|
|
http://www.getpaint.net/index2.html[^]
I haven't really looked at Paint.NET source but I can imagine there's a lot to learn.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Hello,
I have a tab control and on one of the tabs I have the ListView control that has the ItemCheck event. When application starts, the tab that contains the ListView does not have focus. But if I select that tab, the ItemCheck event fires all the time, but only the first time I select the tab. If I start switching the tabs the event does not fire anymore.
What's going on? How can I suppress that event firing for the first time?
Thank you.
|
|
|
|
|
According to MSDN, "the ItemCheck event occurs when the check state of an item changes or when the CheckBoxes property is set to true". Perhaps the first instance of the event occurs when you set the list view's CheckBoxes property?
/ravi
|
|
|
|
|
I´m working with large xml files(about 100MB) and what I have to do is:
- first validate the xml file against a schema
- then insert data from the file to a database
What is the most efficient way to do this? Can anyone help me with this?
cellardoor
|
|
|
|