|
You are right, I've changed this to
this.textBoxRegex.Text = sw.Elapsed.ToString() + " " + match.ToString();
but the results didn't change much:
00:00:00.2823207 36117 for Regex
00:00:00.3306054 36117 for Contains.
|
|
|
|
|
I agree with Griff, and I raise you this...
While what you have may be suitable for your current needs, it may not generalize well. If a library function were doing Contains that way it would likely have the same signature as the existing Contains -- bool Contains ( string , string ) -- and it would have to create the Regex on each call. Your code as shown, knowing that it can use the same Regex instance, avoids this overhead. A more honest implementation may be even less efficient than the numbers Griff found.
|
|
|
|
|
OriginalGriff wrote: han a Regex if only because the Regex has to be parsed!
No. Compilation can be a one time cost and as such is not a factor in general for regex. However after that the regex must still be interpreted. And that cost does not go away.
|
|
|
|
|
Why would you even do this? Regexes are not fast, they are fairly slow, that's the price you pay for them being so flexible ... and when you want something simple that is already provided by a framework method, just use that.
|
|
|
|
|
Hi Experts,
Can anyone explain to me what is the graphicsDeviceservice in XNA? For what I know it serve the same function as CSS.
Can someone explain to me pls?
Thank you
|
|
|
|
|
Take a look here[^].
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
hi all , i want to sent latitude & longitude on click on map
to c# windows form textbox_latitude & textbox_longitude
this code send latitude & longitude on click on map but it send it to html input type="text" name="lat" ,input type="text" name="lng"
i want to transfer var lat , var lng to c# windows form textbox_latitude & textbox_longitude
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Dragable and clickable marker with lat and lang in form</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(30.050077, 31.238594);
var myOptions = {
zoom: 7,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var infowindow = new google.maps.InfoWindow({
content: "Drag marker to position or click to place"
});
infowindow.open(map);
google.maps.event.addListener(map, 'click', function(event) {
var clickedLocation = new google.maps.LatLng(event.latLng);
var marker = new google.maps.Marker({
position: event.latLng,
title:"Marker position",
draggable: true,
map: map
});
infowindow.open(map,marker);
map.setCenter(event.latLng);
google.maps.event.addListener(map, 'click', function(event) {
marker.setMap(null);
});
google.maps.event.addListener(marker, 'dragend', function(event) {
var point = event.latLng;
var lat = point.lat();
var lng = point.lng();
document.getElementById("frmLat").value = lat;
document.getElementById("frmLon").value = lng;
});
var point = event.latLng;
var lat = point.lat();
var lng = point.lng();
document.getElementById("frmLat").value = lat;
document.getElementById("frmLon").value = lng;
});
}
</script>
</head>
<body onLoad="initialize()">
Lat: <input type="text" name="lat" id="frmLat" >
Lng: <input type="text" name="lng" id="frmLon" >
iW3B.info
</body>
</html>
thanks in advance
|
|
|
|
|
Are you using the WebBrowser control?
If so, add a script to the HTML document that returns the values of interest; then (from the Windows Form) call the WebBrowser.InvokeScript method with the name of the script and populate the form's controls / properties with the returned values.
|
|
|
|
|
|
|
I failed to mention that you need to specify that the WinForm object is going to be used for the scripting from JavaScript. The following property should be updated from your WinForm class:
webBrowser1.ObjectForScripting = this; Sorry for this oversight.
|
|
|
|
|
hey all,
i am new to c#
what am i trying to do is
make a panel in form1 and free hand draw on that and it should automatically display on the panel in form2.
can i do that?
and can anyone post some examples i can use?
please thanks a lot
|
|
|
|
|
You should capture the drawing elements and their parameters into some data structures, and paint the drawing from that data; if you want to see more than one instance, just paint as many as you like.
This article[^] could offer some useful guide lines.
|
|
|
|
|
thanks for the reply
i mean do you have any examples that i can work with
i am really really new to c#
|
|
|
|
|
Then go to a book store, look at a range of C# books, choose one or two that look interesting to you, buy them, and study them. Once you got the fundamentals, start reading some articles, a lot of good stuff can be found on this very site. Programming is work, it isn't finger painting.
|
|
|
|
|
Luc Pattyn wrote: Programming is work, it isn't finger painting. Killer sig material.
/ravi
|
|
|
|
|
0down votefavorite
I have a collection of NodeModel objects:
public class NodeModel : ViewModelBase
{
public Guid Id { get; set; }
public string Caption { get; set; }
public string Description { get; set; }
public NodeType Type { get; set; }
public List<NodeModel> Children { get; set; }
}
I need to provide Move Up and Move Down functions. To move an item up in the collection, it seems like I would need to know the the item's parent.
True is, I'm not really sure how to implement this. Anyone done this? Can you point me in the right direction?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
|
Mark, I don't think a linked list is a good basis for a model of a hierarchy.
best, Bill
"Humans are amphibians ... half spirit and half animal ... as spirits they belong to the eternal world, but as animals they inhabit time. This means that while their spirit can be directed to an eternal object, their bodies, passions, and imaginations are in continual change, for to be in time, means to change. Their nearest approach to constancy, therefore, is undulation: the repeated return to a level from which they repeatedly fall back, a series of troughs and peaks.” C.S. Lewis
|
|
|
|
|
Your objects seems akin to Controls on a WinForm, so why not use their model? Each Control has a ControlCollection holding its children, and a Parent property pointing to its parent (null for any topmost Control).
When in doubt, look for similar situations and reuse existing concepts.
|
|
|
|
|
|
Yes, I'm using WPF and ObservableCollections. The question then is, in a hierchical collection, how do you know a node's index position? Seems like I'll need to recurse.
If it's not broken, fix it until it is
|
|
|
|
|
See my comments a couple of threads down. You need to be crystal clear about what your hierarchy (and the internal relationships - parent/child/sibling/etc) represent, so you can clearly define your add/delete/move/whatever operations.
Yes, given that a hierarchical structure is involved, you will be up for recursion (or possibly an equivalent iteration). For a many-children "tree", search the big G or Wikip for "trie". That might just hand it to you on a platter.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Give a node a reference to its parent? That's what I've done in every tree-like data structure I've ever built.
|
|
|
|
|
Sounds like a good idea. Do you worry at all about dangling references?
If it's not broken, fix it until it is
|
|
|
|