|
Revision revised... I realized that I could simply return the comparison, as it is bool.
private static bool matchList<T>(List<T> List1, List<T> List2)
{
if (List1 == null || List2 == null) return false;
return ((List1.Count == List2.Count) && (List1.Count == List1.Intersect(List2).Count()));
}
|
|
|
|
|
An interesting approach. thanks.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
|
Hello,
I am trying to add google maps in my C# application but i can't figure out how to do it because i am new in C#. I've checked all of the online tutorials but nothing comes up. I want to add google maps in the rectangle shown in the picture below. If any one can help me this would be very good for me.
http://yfrog.com/0kgoogleaep[^]
Thanks,
John
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:27am.
|
|
|
|
|
But i want to take information from the map. For example when i click in London i want to store it for later use!
|
|
|
|
|
You will need to register your URL with Google in order to use the maps API. They will provide a script block that must be included in your header.
You will also need a map canvas div, and use JS to create a new GMap2 object (with the div name as a parameter), create the icon objects you need, and use addOverlay methods to place icon instances at specific latitude/longitudes. Personally, I wrap all of these into a function that is called from BODY onLoad.
I would recommend reading the API documentation carefully. They have examples, also.
|
|
|
|
|
can you please link me with an example like this?
thanks for you help mate
|
|
|
|
|
Here is an example. Note that if you want to add markers using C#, you will need to create the entire "initialize" function in your code (that is, create C# code that writes the JavaScript code).
Hope this helps.
<html lang="en-us">
<head>
<title>Map Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://maps.google.com/maps?file=<Google will provide this>" type="text/javascript"></script>
<script type="text/javascript">
function initialize()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(20, 0), 2);
map.enableScrollWheelZoom();
var redIcon = new GIcon(G_DEFAULT_ICON);
redIcon.image = "Images/RedCircle.png";
redIcon.shadow = "Images/transparent.png";
redIcon.iconSize = new GSize(32, 32);
redIcon.shadowSize = redIcon.iconSize;
redIcon.iconAnchor = new GPoint(16, 16);
map.addOverlay(new GMarker(new GLatLng(50, 110), { icon:redIcon } ));
map.addOverlay(new GMarker(new GLatLng(100, 200), { icon:redIcon } ));
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 1600px; height: 1000px"></div>
</body>
</html>
|
|
|
|
|
|
OK, this program is from a class I'm taking, it's an example out of our book. You have four classes, D inherits from C, C from B and B from A. I kind of understand how this works but I'm not sure.
Question. Is this considered a single object? Only one object is created but do the references make the other classes(or the methods within them) part of the same object?
I think I understand the rest.
1.) D is called and outputs 'D' becuase that is the method within D.
2.) Since C is virtual and it's child class D overries it, C also outputs 'D'.
3.) Since C is declared 'new' that hides C from B (I assume it also hides D from B) and therefore B outputs it own method and displays 'B'
4.) A is virtual and since its child class B overrides it, it also outputs 'B'.
Sorry, but I think my brain actually froze for a while when I was trying to figure this out and I'm just trying to see if anyone has any input or knows if I'm right.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Example
{
class A
{
public virtual void M() { Console.WriteLine("A"); }
}
class B : A
{
public override void M() { Console.WriteLine("B"); }
}
class C : B
{
new public virtual void M() { Console.WriteLine("C"); }
}
class D : C
{
public override void M() { Console.WriteLine("D"); }
}
class Program
{
static void Main(string[] args)
{
D d = new D();
C c = d;
B b = c;
A a = b;
d.M();
c.M();
b.M();
a.M();
}
}
}
|
|
|
|
|
It is indeed one object, but depending on how you type the object, you're getting different methods to execute. The type you reference an object by can definitely impact what functionality is executed.
It's kind of like explicitly implementing interfaces, check this[^] out.
|
|
|
|
|
Thank you, I thought that it was the same object but I wasn't sure.
I think you answered the 'why' question also.
Your saying that that like interfaces (I'm still trying to grasp those also) You can take the same data but manipulate it differently.
With an interface you explicitly cast the data using the interface you want.
With inheratance you use the same object but use a different reference to the object.
|
|
|
|
|
It sounds like your close to the correct understanding. Be aware though, this is NOT a normal situation in coding. The only reason you would ever use new is that the member is NOT virtual and you need to override its functionality. Because the method is virtual, there is really no need to shadow it with new . Typically shadowing can get you into a lot of confusion if you're not careful, hence why when its not necessary it is strictly avoided.
As an example of why its not needed, if you change the definition of the method in C to:
class C : B
{
public override void M() { Console.WriteLine("C"); }
}
It'll print out four "D"s.
As for interfaces, they don't represent a class you can create (eg. new IList() ), but rather just an expected contract of functionality.
I mention explicit implementation of interfaces because they represent something similar to the behavior seen in the code you posted. Basically, how you reference an object determines exactly what functionality is called.
When you down cast class D to C, that is an implicit cast (ie. .NET assumes you mean to do that). It'd be exactly the same as if you had typed:
C c = (C)d;
Ok, he comes some really confusing stuff, hopefully it won't make things worse.
If you look at the reflected IL code of the Main method, you'll see this:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 1
.locals init (
[0] class Example.D d,
[1] class Example.C c,
[2] class Example.B b,
[3] class Example.A a)
L_0000: nop
L_0001: newobj instance void Example.D::.ctor()
L_0006: stloc.0
L_0007: ldloc.0
L_0008: stloc.1
L_0009: ldloc.1
L_000a: stloc.2
L_000b: ldloc.2
L_000c: stloc.3
L_000d: ldloc.0
L_000e: callvirt instance void Example.C::M()
L_0013: nop
L_0014: ldloc.1
L_0015: callvirt instance void Example.C::M()
L_001a: nop
L_001b: ldloc.2
L_001c: callvirt instance void Example.A::M()
L_0021: nop
L_0022: ldloc.3
L_0023: callvirt instance void Example.A::M()
L_0028: nop
L_0029: ret
}
I've underlined the calls to d.M(), c.M(), etc. You'll notice that its going back to the class that defines the original signature of the method. Because of the 'new' keyword, that inheritance starts over so to speak. So, from a code perspective, it'll burrow its way through the currently defined type you're referencing it as, until it finds a 'new' keyword or the 'virtual' keyword. From there, it'll find the furthest up the inheritance chain it can go before it reaches the real type of the class or another 'new' keyword. By using 'new', you break all inheritance hence forth.
I hope that helps you, rather than confuses you.
|
|
|
|
|
hi,
as i told in recent post, i need to a way to place generated serial number into my application. but i build my application using msbuild, bcoz of dynammic build i cant change the source code to place serial number in it, is there any way to place serial number of software without changing source code manually??? or a way to define serial of software?
note: I need this serial number to be checked in my hardlock validation routine!
|
|
|
|
|
Well, you could write a utility to patch the executable, but what about obfuscation? Are you going to obfuscate your code? If so (and believe me you should), you have to do it AFTER you patch the exe because (decent) obfuscation utilities typically encrypt strings.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
thanx for ur answer! u mean there isn't any way to add serial number to software? could u explain how obfuscate my code?
|
|
|
|
|
I figured you didn't want to spend the money on a commercial solution.
Obfuscation makes it difficult/impossible to reverse engineer your code (which is easy to do on a .net assembly). Google ".Net Obfuscation tools" to find a list of viable candidates.
BTW, Visual Studio comes with an obfuscation tool, but it's so featureless as to be completely worthless. You have to actually spend money on a 3rd party product, and this can cost from $150 to THOUSANDS of dollars. If your app written in WPF or Silverlight, there's only one obfuscator that can obfuscate it, but I don't remember what the name of it is.
As far as a serial number tool, you may be able to find one that can work on obfuscated assemblies, but I dont' know. Again, google is your friend.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hellow i m new to C# and i have a project to find duplicate values in two or more Excel files.
to ope the files i use the :
Microsoft.Jet.OLEDB.4.0
and afther the conection i get a dataTable.
the DataTable is inserten in tow a data set that contains all my "files"
Hope this dose the write thing....
i m stuck at finding the duplicates....
can someone point me in the write direction?
10x
|
|
|
|
|
|
Hi all,
I want to use WebBrowser control as a file viewer, but my files are stored in database.
I can open files by WebBrowser control using WebBrowse.Navigate() method.
But,
I want to load my files directly from database to WebBrowser control, instead of saving them to hard disk then loading to WebBrowser control using WebBrowse.Navigate() method.
Can I pass binary data of a file from database to WebBrowser control?
please help...
|
|
|
|
|
With WebBrowser, you either provide a URL to the Navigate() method, which causes the Control to go fetch the corresponding web page, or you provide an HTML document to its DocumentText property, so you provide the page content directly, nothing gets fetched.
The DocumentText also accepts non-HTML documents very much like Internet Explorer does. If you set it to "aha" it will show the word in a default font, size, color, etc. And probably, not tested, if you feed it a PDF document (the binary content of a PDF file) it will display that too, assuming your system has the necessary code to do so, i.e. Internet Explorer is doing that too.
You should experiment a bit.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
OK thank you Luc ...
Now, how to:
Luc Pattyn wrote: feed it a PDF document (the binary content of a PDF file)
|
|
|
|
|
You can set the DocumentStream property of the control. The specified stream will be used to read the data that will be rendered.
|
|
|
|
|
Thank you Giorgi, but it works perfectly with images only
I tried .doc and .pdf files but a garbage data is displayed
i'm using MemoryStream
|
|
|
|