qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
270,677
<p>How do I access specific sections of man pages?</p>
[ { "answer_id": 270694, "author": "Jason Coco", "author_id": 34218, "author_profile": "https://Stackoverflow.com/users/34218", "pm_score": 5, "selected": true, "text": "<p>Put the section number in front of the item you want to reference. For example, to access the sysctl function from th...
2008/11/06
[ "https://Stackoverflow.com/questions/270677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30924/" ]
How do I access specific sections of man pages?
Put the section number in front of the item you want to reference. For example, to access the sysctl function from the library section, you can write: ``` man 3 sysctl ``` and to access the sysctl tool from the system administrator's section, you would write: ``` man 8 sysctl ```
270,695
<p>Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB. Is there a way to have an insert statement return a value? I have a sequence set up to number entries as they go into the database, but I need that value to come back after the insert so I can do some manipulation to the set I jus...
[ { "answer_id": 270698, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 0, "selected": false, "text": "<p>If this value is the key the database creates, you've ran into a good example why you should use UUIDs as your table ke...
2008/11/06
[ "https://Stackoverflow.com/questions/270695", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12545/" ]
Working with an Oracle 9i database from an ASP.NET 2.0 (VB) application using OLEDB. Is there a way to have an insert statement return a value? I have a sequence set up to number entries as they go into the database, but I need that value to come back after the insert so I can do some manipulation to the set I just ent...
Some possibilities: 1) Use the RETURNING clause: ``` INSERT INTO emp (empno, ename) VALUES (emp_seq.NEXTVAL, 'ANDREWS') RETURNING empno INTO :variable; ``` 2) Use the sequence CURRVAL: ``` INSERT INTO emp (empno, ename) VALUES (emp_seq.NEXTVAL, 'ANDREWS'); SELECT emp_seq.CURRVAL INTO :variable FROM DUAL; ``` CUR...
270,708
<p>I have a char array buffer that I am using to store characters that the user will input one by one. My code below works but has a few glitches that I can't figure out:</p> <ol> <li>when I execute a printf to see what's in Buffer, it does fill up but I get garbage characters at the end</li> <li>it won't stop at 8 c...
[ { "answer_id": 270713, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 6, "selected": true, "text": "<p>You have to end the string with a <code>\\0</code> character. That's why they are called zero terminated strings.</...
2008/11/06
[ "https://Stackoverflow.com/questions/270708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28462/" ]
I have a char array buffer that I am using to store characters that the user will input one by one. My code below works but has a few glitches that I can't figure out: 1. when I execute a printf to see what's in Buffer, it does fill up but I get garbage characters at the end 2. it won't stop at 8 characters despite be...
You have to end the string with a `\0` character. That's why they are called zero terminated strings. It is also wise to allocate 1 extra char to hold the `\0`.
270,724
<p>I'm checking out the Delphi 2009 Trial, but run into problems with the generics stuff right away.</p> <p>The following code does not compile, and I haven't the slightest idea why it's giving me E2015 for the Equals() method:</p> <pre><code>type TPrimaryKey&lt;T&gt; = class(TObject) strict private fValue: T...
[ { "answer_id": 270789, "author": "Angus Glashier", "author_id": 35063, "author_profile": "https://Stackoverflow.com/users/35063", "pm_score": 2, "selected": false, "text": "<p>You can't use operators with untyped generics. See <a href=\"https://forums.codegear.com/message.jspa?messageID=...
2008/11/06
[ "https://Stackoverflow.com/questions/270724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30568/" ]
I'm checking out the Delphi 2009 Trial, but run into problems with the generics stuff right away. The following code does not compile, and I haven't the slightest idea why it's giving me E2015 for the Equals() method: ``` type TPrimaryKey<T> = class(TObject) strict private fValue: T; public constructor ...
What if T is a string? What if it's a TSize record? Without constraining T (e.g. with <T :class>), you can't be sure that the comparison will be meaningful. If, instead, you wanted to compare two values of type T, you can use the Generics.Defaults unit and use: ``` TEqualityComparer<T>.Default.Equals(x, y) ``` to ...
270,745
<p>I have multiple Network Interface Cards on my computer, each with its own IP address.</p> <p>When I use <code>gethostbyname(gethostname())</code> from Python's (built-in) <code>socket</code> module, it will only return one of them. How do I get the others?</p>
[ { "answer_id": 270777, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 0, "selected": false, "text": "<p>You should directly obtain all IP configured IP addresses, e.g. by running ifconfig and parsing its output (it'...
2008/11/06
[ "https://Stackoverflow.com/questions/270745", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35305/" ]
I have multiple Network Interface Cards on my computer, each with its own IP address. When I use `gethostbyname(gethostname())` from Python's (built-in) `socket` module, it will only return one of them. How do I get the others?
Use the [`netifaces`](https://pypi.org/project/netifaces/) module. Because networking is complex, using netifaces can be a little tricky, but here's how to do what you want: ``` >>> import netifaces >>> netifaces.interfaces() ['lo', 'eth0'] >>> netifaces.ifaddresses('eth0') {17: [{'broadcast': 'ff:ff:ff:ff:ff:ff', 'ad...
270,792
<p>I have the following xml I'd like to deserialize into a class</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;root&gt; &lt;element1&gt;String1&lt;/element1&gt; &lt;element2&gt;String2&lt;/element2&gt; &lt;/root&gt; </code></pre> <p>I am trying to serialize it into the following class:</p> <pr...
[ { "answer_id": 270809, "author": "Brody", "author_id": 17131, "author_profile": "https://Stackoverflow.com/users/17131", "pm_score": 4, "selected": true, "text": "<p>You can't serialise/deserialise internal properties - They have to be public.</p>\n" }, { "answer_id": 270821, ...
2008/11/06
[ "https://Stackoverflow.com/questions/270792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12497/" ]
I have the following xml I'd like to deserialize into a class ``` <?xml version="1.0" encoding="utf-8" ?> <root> <element1>String1</element1> <element2>String2</element2> </root> ``` I am trying to serialize it into the following class: ```csharp [XmlRoot("root")] public class root { [XmlEle...
You can't serialise/deserialise internal properties - They have to be public.
270,811
<pre><code>cmd /C "myshortcut1.lnk" cmd /C "myshortcut2.lnk" </code></pre> <p>Works, but gives me a pop-up DOS window which, when closed, kills my two loaded programs. Same is true for this:</p> <pre><code>start /B cmd /C "1.lnk" start /B cmd /C "2.lnk" start /B cmd /C "3.lnk" start /B cmd /C "4.lnk" </code></pre>
[ { "answer_id": 270857, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 5, "selected": true, "text": "<p>The MySQL JDBC driver times out after 8 hours of inactivity and drops the connection.</p>\n\n<p>You can set <code>au...
2008/11/06
[ "https://Stackoverflow.com/questions/270811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34594/" ]
``` cmd /C "myshortcut1.lnk" cmd /C "myshortcut2.lnk" ``` Works, but gives me a pop-up DOS window which, when closed, kills my two loaded programs. Same is true for this: ``` start /B cmd /C "1.lnk" start /B cmd /C "2.lnk" start /B cmd /C "3.lnk" start /B cmd /C "4.lnk" ```
The MySQL JDBC driver times out after 8 hours of inactivity and drops the connection. You can set `autoReconnect=true` in your JDBC URL, and this causes the driver to reconnect if you try to query after it has disconnected. But this has side effects; for instance session state and transactions cannot be maintained ove...
270,825
<p>Has anyone else run into this problem before? I've got a method that calls a generic method with a delegate, inside of a generic class. I've marked the class as Serializable, and it serializes without complaint. But, when I try to deserialize an object of this class, it pegs the CPU and hangs the machine.</p> <p>Co...
[ { "answer_id": 270858, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 0, "selected": false, "text": "<p>First of all, Dictionary&lt;> already implements ISerializable, so you don't need to specify that explicity!</p>\n\n<p>Second, ...
2008/11/06
[ "https://Stackoverflow.com/questions/270825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35308/" ]
Has anyone else run into this problem before? I've got a method that calls a generic method with a delegate, inside of a generic class. I've marked the class as Serializable, and it serializes without complaint. But, when I try to deserialize an object of this class, it pegs the CPU and hangs the machine. Code example...
Are you using VS2008 SP1? There's a known problem with SP1. <https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361615>
270,835
<p>I am trying to provide my own labelFunction for a CategoryAxis programatically but am completely stumped. The regular way is to do it in your MXML file, but I want to do it in my Actionscript file.</p> <p>The regular way of doing it is:</p> <pre><code>&lt;mx:Script&gt; &lt;![CDATA[ private function cate...
[ { "answer_id": 271352, "author": "Mitch Haile", "author_id": 28807, "author_profile": "https://Stackoverflow.com/users/28807", "pm_score": 1, "selected": false, "text": "<p>This question got me curious, so I went off and tried it.</p>\n\n<p>The labelFunction on CategoryAxis has a slightl...
2008/11/06
[ "https://Stackoverflow.com/questions/270835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
I am trying to provide my own labelFunction for a CategoryAxis programatically but am completely stumped. The regular way is to do it in your MXML file, but I want to do it in my Actionscript file. The regular way of doing it is: ``` <mx:Script> <![CDATA[ private function categoryAxis_labelFunc(item:Object...
Well, I'm baffled by your problem, because it works absolutely fine for me. I took the example application for CategoryAxis from the Adobe Flex site: <http://livedocs.adobe.com/flex/3/langref/index.html?mx/charts/CategoryAxis.html&mx/charts/class-list.html>, added your code verbatim (well except for adding package an...
270,845
<p>I've been trying to come up with a way to write generic repositories that work against various data stores:</p> <pre><code>public interface IRepository { IQueryable&lt;T&gt; GetAll&lt;T&gt;(); void Save&lt;T&gt;(T item); void Delete&lt;T&gt;(T item); } public class MemoryRepository : IRepository {...} p...
[ { "answer_id": 271216, "author": "cfeduke", "author_id": 5645, "author_profile": "https://Stackoverflow.com/users/5645", "pm_score": 3, "selected": false, "text": "<ol>\n<li><p>The first approach is feasible, I have done something similar in the past when I wrote my own mapping framework...
2008/11/07
[ "https://Stackoverflow.com/questions/270845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been trying to come up with a way to write generic repositories that work against various data stores: ``` public interface IRepository { IQueryable<T> GetAll<T>(); void Save<T>(T item); void Delete<T>(T item); } public class MemoryRepository : IRepository {...} public class SqlRepository : IRepositor...
1. The first approach is feasible, I have done something similar in the past when I wrote my own mapping framework that targeted RDBMS and `XmlWriter`/`XmlReader`. You can use this sort of approach to ease unit testing, though I think now we have superior OSS tools for doing just that. 2. The second approach is what I ...
270,874
<p>I have a DataTrigger defined in my XAML which I want to use in several places. Is it possible to define it as a resource and then share it?</p> <p>Here's my trigger:</p> <pre><code>&lt;TextBlock.Style&gt; &lt;Style&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding HasCurrentTest}...
[ { "answer_id": 270904, "author": "MrSlippers", "author_id": 35290, "author_profile": "https://Stackoverflow.com/users/35290", "pm_score": 1, "selected": false, "text": "<p>If the style is in the Windows.Resources with a key, each element can add it to their own style like this.</p>\n\n<p...
2008/11/07
[ "https://Stackoverflow.com/questions/270874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
I have a DataTrigger defined in my XAML which I want to use in several places. Is it possible to define it as a resource and then share it? Here's my trigger: ``` <TextBlock.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding HasCurrentTest}" Value="True"> <Setter Pr...
As a comment on my own post, I've just seen a much better way to do this anyway - I should be using the built-in BooleanToVisibilityConverter, then I can just do this: ``` <Window.Resources> <BooleanToVisibilityConverter x:Key="BoolToVis" /> </Window.Resources> ``` then... ``` <TextBlock Visibility="{Binding Ha...
270,879
<p>I'm starting a new application and looking at using an ORM -- in particular, SQLAlchemy.</p> <p>Say I've got a column 'foo' in my database and I want to increment it. In straight sqlite, this is easy:</p> <pre><code>db = sqlite3.connect('mydata.sqlitedb') cur = db.cursor() cur.execute('update table stuff set foo ...
[ { "answer_id": 270891, "author": "Matthew Schinckel", "author_id": 188, "author_profile": "https://Stackoverflow.com/users/188", "pm_score": 1, "selected": false, "text": "<p>Withough testing, I'd try:</p>\n\n<pre><code>for c in session.query(Stuff).all():\n c.foo = c.foo+1\nsession....
2008/11/07
[ "https://Stackoverflow.com/questions/270879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15154/" ]
I'm starting a new application and looking at using an ORM -- in particular, SQLAlchemy. Say I've got a column 'foo' in my database and I want to increment it. In straight sqlite, this is easy: ``` db = sqlite3.connect('mydata.sqlitedb') cur = db.cursor() cur.execute('update table stuff set foo = foo + 1') ``` I fi...
SQLAlchemy's ORM is meant to be used together with the SQL layer, not hide it. But you do have to keep one or two things in mind when using the ORM and plain SQL in the same transaction. Basically, from one side, ORM data modifications will only hit the database when you flush the changes from your session. From the ot...
270,884
<p>I've been doing some socket programming to transmit information across the wire. I've run into a problem with DataOutputStream.writeUTF(). It seems to allow strings of up to 64k but I have a few situations where I can run over this. Are there any good alternatives that support larger strings or do I need to roll ...
[ { "answer_id": 270915, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 1, "selected": false, "text": "<p>You should be able to use <a href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStreamWriter.html\" rel...
2008/11/07
[ "https://Stackoverflow.com/questions/270884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/269171/" ]
I've been doing some socket programming to transmit information across the wire. I've run into a problem with DataOutputStream.writeUTF(). It seems to allow strings of up to 64k but I have a few situations where I can run over this. Are there any good alternatives that support larger strings or do I need to roll my own...
It actually uses a two bytes to write the length of the string before using an algorithm that compacts it into one, two or three bytes per character. (See the documentation on java.io.DataOutput) It is close to UTF-8, but even though documented as being so, there are compatibility problems. If you are not terribly worr...
270,895
<p>This fails:</p> <pre><code>my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-$_" =&gt; 1 } @a; </code></pre> <p>with this error:</p> <pre><code>Not enough arguments for map at foo.pl line 4, near "} @a" </code></pre> <p>but this works:</p> <pre><code>my @a = ("a", "b", "c", "d", "e"); my %h = map { "pref...
[ { "answer_id": 270905, "author": "Leonardo Herrera", "author_id": 7841, "author_profile": "https://Stackoverflow.com/users/7841", "pm_score": 5, "selected": true, "text": "<p>Because Perl is guessing an EXPR (a hash reference, for example) instead of a BLOCK. This should work (note the '...
2008/11/07
[ "https://Stackoverflow.com/questions/270895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14032/" ]
This fails: ``` my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-$_" => 1 } @a; ``` with this error: ``` Not enough arguments for map at foo.pl line 4, near "} @a" ``` but this works: ``` my @a = ("a", "b", "c", "d", "e"); my %h = map { "prefix-" . $_ => 1 } @a; ``` why?
Because Perl is guessing an EXPR (a hash reference, for example) instead of a BLOCK. This should work (note the '+' symbol): ``` my @a = ("a", "b", "c", "d", "e"); my %h = map { +"prefix-$_" => 1 } @a; ``` See <http://perldoc.perl.org/functions/map.html>.
270,917
<p>I know it is a good practice to declare virtual destructors for base classes in C++, but is it always important to declare <code>virtual</code> destructors even for abstract classes that function as interfaces? Please provide some reasons and examples why.</p>
[ { "answer_id": 270925, "author": "Airsource Ltd", "author_id": 18017, "author_profile": "https://Stackoverflow.com/users/18017", "pm_score": 9, "selected": true, "text": "<p>It's even more important for an interface. Any user of your class will probably hold a pointer to the interface, n...
2008/11/07
[ "https://Stackoverflow.com/questions/270917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4599/" ]
I know it is a good practice to declare virtual destructors for base classes in C++, but is it always important to declare `virtual` destructors even for abstract classes that function as interfaces? Please provide some reasons and examples why.
It's even more important for an interface. Any user of your class will probably hold a pointer to the interface, not a pointer to the concrete implementation. When they come to delete it, if the destructor is non-virtual, they will call the interface's destructor (or the compiler-provided default, if you didn't specify...
270,918
<p>I would like to create a batch script, to go through 20,000 links in a DB, and weed out all the 404s and such. How would I get the HTTP status code for a remote url?</p> <p>Preferably not using curl, since I dont have it installed. </p>
[ { "answer_id": 270966, "author": "Adam Pierce", "author_id": 5324, "author_profile": "https://Stackoverflow.com/users/5324", "pm_score": 5, "selected": true, "text": "<p>CURL would be perfect but since you don't have it, you'll have to get down and dirty with sockets. The technique is:</...
2008/11/07
[ "https://Stackoverflow.com/questions/270918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would like to create a batch script, to go through 20,000 links in a DB, and weed out all the 404s and such. How would I get the HTTP status code for a remote url? Preferably not using curl, since I dont have it installed.
CURL would be perfect but since you don't have it, you'll have to get down and dirty with sockets. The technique is: 1. Open a socket to the server. 2. Send an HTTP HEAD request. 3. Parse the response. Here is a quick example: ``` <?php $url = parse_url('http://www.example.com/index.html'); $host = $url['host']; $...
270,919
<p>I am looking for an example of how to do the following in VB.net with Parallel Extensions.</p> <pre><code>Dim T As Thread = New Thread(AddressOf functiontodowork) T1.Start(InputValueforWork) </code></pre> <p>Where I'm getting stuck is on how to pass into the task my parameter InputValueforWork</p> <pre><code>Dim ...
[ { "answer_id": 271266, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 0, "selected": false, "text": "<p>Not necessarily the most helpful answer I know, but in C# you could do this with a closure:</p>\n\n<pre><code>var T = T...
2008/11/07
[ "https://Stackoverflow.com/questions/270919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35331/" ]
I am looking for an example of how to do the following in VB.net with Parallel Extensions. ``` Dim T As Thread = New Thread(AddressOf functiontodowork) T1.Start(InputValueforWork) ``` Where I'm getting stuck is on how to pass into the task my parameter InputValueforWork ``` Dim T As Tasks.Task = Tasks.Task.Create(A...
I solved my own question. you have to pass in an array with the values. ``` Dim A(0) as Int32 A(0) = 1 Tasks.Task.Create(AddressOf TransferData, A) ```
270,924
<p>I've been reading a text about an extension to C# and at one point it says that "An attribute decoration X may only be applied to fields of type Y."</p> <p>I haven't been able to find a definition for attribute decoration, and I'm not making much sense out of this by exchanging the two.</p>
[ { "answer_id": 271266, "author": "Ana Betts", "author_id": 5728, "author_profile": "https://Stackoverflow.com/users/5728", "pm_score": 0, "selected": false, "text": "<p>Not necessarily the most helpful answer I know, but in C# you could do this with a closure:</p>\n\n<pre><code>var T = T...
2008/11/07
[ "https://Stackoverflow.com/questions/270924", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I've been reading a text about an extension to C# and at one point it says that "An attribute decoration X may only be applied to fields of type Y." I haven't been able to find a definition for attribute decoration, and I'm not making much sense out of this by exchanging the two.
I solved my own question. you have to pass in an array with the values. ``` Dim A(0) as Int32 A(0) = 1 Tasks.Task.Create(AddressOf TransferData, A) ```
270,927
<p>The situation is this. I have an asp.net webservice application...say a page called api.asmx</p> <p>In the code behind I have several methods, for example:</p> <pre><code>[WebMethod(Description="Method1")] public int GetSomething(int num1, int num2){ try{ return SomeObject.DatabaseCall.DoSomething(num1, num...
[ { "answer_id": 270970, "author": "Keltex", "author_id": 28260, "author_profile": "https://Stackoverflow.com/users/28260", "pm_score": 0, "selected": false, "text": "<p>Your LogError method could call <a href=\"http://msdn.microsoft.com/en-us/library/system.environment.stacktrace.aspx\" r...
2008/11/07
[ "https://Stackoverflow.com/questions/270927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The situation is this. I have an asp.net webservice application...say a page called api.asmx In the code behind I have several methods, for example: ``` [WebMethod(Description="Method1")] public int GetSomething(int num1, int num2){ try{ return SomeObject.DatabaseCall.DoSomething(num1, num2); } catch(Except...
Any unhandled exceptions will be bubbled up to your Application\_Error event in the Global.asax file. From there, you can call Server.GetLastError() to retrieve the Exception instance. Once you have the exception, you can look at the stack trace. You will also have access to the Request object so you can see exactly ...
270,933
<p>I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout.</p> <p>On the client side I use plink to execute the script and stream stdin to a file.</p> <p>This almost works.</p> <p>It seems that the cp command outputs the file name being cop...
[ { "answer_id": 270935, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 5, "selected": true, "text": "<p>It's not cp, it's tar. You are passing it -v, which makes it print the names of the files.</p>\n" }, { "answer_id...
2008/11/07
[ "https://Stackoverflow.com/questions/270933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1851/" ]
I have a shell script which copies a few files to the current directory, compresses them, and streams the compressed file to stdout. On the client side I use plink to execute the script and stream stdin to a file. This almost works. It seems that the cp command outputs the file name being copied when its executed fr...
It's not cp, it's tar. You are passing it -v, which makes it print the names of the files.
270,947
<p>I write a singleton c++ in the follow way:</p> <pre><code>class A { private: static A* m_pA; A(); virtual ~A(); public: static A* GetInstance(); static void FreeInstance(); void WORK1(); void WORK2(); void WORK3(); } } A* A::GetInstance(...
[ { "answer_id": 270957, "author": "Evan Teran", "author_id": 13430, "author_profile": "https://Stackoverflow.com/users/13430", "pm_score": 5, "selected": true, "text": "<p>You can avoid needing to delete it by using a static object like this:</p>\n\n<pre><code>if(m_pA == 0) {\n static ...
2008/11/07
[ "https://Stackoverflow.com/questions/270947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
I write a singleton c++ in the follow way: ``` class A { private: static A* m_pA; A(); virtual ~A(); public: static A* GetInstance(); static void FreeInstance(); void WORK1(); void WORK2(); void WORK3(); } } A* A::GetInstance() { if (m_...
You can avoid needing to delete it by using a static object like this: ``` if(m_pA == 0) { static A static_instance; m_pA = &static_instance; } ```
270,948
<p>Are there any tricks for preventing SQL Server from entitizing chars like &amp;, &lt;, and >? I'm trying to output a URL in my XML file but SQL wants to replace any '&amp;' with '<code>&amp;amp;</code>'</p> <p>Take the following query:</p> <pre><code>SELECT 'http://foosite.com/' + RTRIM(li.imageStore) + '...
[ { "answer_id": 271000, "author": "ykaganovich", "author_id": 10026, "author_profile": "https://Stackoverflow.com/users/10026", "pm_score": 5, "selected": true, "text": "<p>What SQL Server generates is correct. What you expect to see is not well-formed XML. The reason is that <code>&amp;<...
2008/11/07
[ "https://Stackoverflow.com/questions/270948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19389/" ]
Are there any tricks for preventing SQL Server from entitizing chars like &, <, and >? I'm trying to output a URL in my XML file but SQL wants to replace any '&' with '`&amp;`' Take the following query: ``` SELECT 'http://foosite.com/' + RTRIM(li.imageStore) + '/ImageStore.dll?id=' + RTRIM(li.imageID) ...
What SQL Server generates is correct. What you expect to see is not well-formed XML. The reason is that `&` character signifies the start of an entity reference, such as `&amp;`. See the [XML specification](http://www.w3.org/TR/REC-xml/#sec-references) for more information. When your XML parser parses this string out ...
271,015
<p>I need to write a Stored procedure in SQL server whose data returned will be used to generate a XML file.</p> <p>My XML file to be in structure of </p> <pre><code>&lt;root&gt; &lt;ANode&gt;&lt;/ANode&gt; &lt;BNode&gt;&lt;/BNode&gt; &lt;CNode&gt; &lt;C1Node&gt; &lt;C11Node&gt;&lt;/C11Node&gt; &lt;C12Node&...
[ { "answer_id": 271191, "author": "Kozyarchuk", "author_id": 52490, "author_profile": "https://Stackoverflow.com/users/52490", "pm_score": 2, "selected": false, "text": "<p>I wouldn't recommend doing this in a stored proc. If created in language such as C#/Python or Java will make the co...
2008/11/07
[ "https://Stackoverflow.com/questions/271015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3113/" ]
I need to write a Stored procedure in SQL server whose data returned will be used to generate a XML file. My XML file to be in structure of ``` <root> <ANode></ANode> <BNode></BNode> <CNode> <C1Node> <C11Node></C11Node> <C12Node></C12Node> </C1Node> <C2Node> <C21Node></C21Node> <C22Node></C22No...
See     [Nesting XML-returning scalar valued functions](https://stackoverflow.com/questions/147897/in-sql-server-can-i-insert-multiple-nodes-into-xml-from-a-table#148877) Once you get the hang of the nesting, and are willing to write the number of scalar-valued functions necessary to construct the node segments from...
271,021
<p>I've recently seen occasional problems with stored procedures on a legacy system which displays error messages like this:</p> <blockquote> <p>Server Message: Number 10901, Severity 17: This query requires <em>X</em> auxiliary scan descriptors but currently there are only <em>Y</em> auxiliary scan descrip...
[ { "answer_id": 271660, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": true, "text": "<p>You don't say what version of Sybase you are on but the following is good for ASE 12.5 onwards.</p>\n\n<p>I suspect that it'...
2008/11/07
[ "https://Stackoverflow.com/questions/271021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1030/" ]
I've recently seen occasional problems with stored procedures on a legacy system which displays error messages like this: > > Server Message: Number 10901, Severity 17: > This query requires *X* auxiliary scan > descriptors but currently there are > only *Y* auxiliary scan descriptors > available. Either raise t...
You don't say what version of Sybase you are on but the following is good for ASE 12.5 onwards. I suspect that it's the addition of the new index that's thrown out the query plan for that stored procedure. Have you tried running ``` update statistics *table_name* ``` on it? If that fails you can find out how many ...
271,043
<p>I'm using jQuery to post a form to a php file, simple script to verify user details.</p> <pre><code>var emailval = $("#email").val(); var invoiceIdval = $("#invoiceId").val(); $.post("includes/verify.php", {invoiceId:invoiceIdval , email:emailval }, function(data) { //stuff here. }); </co...
[ { "answer_id": 271064, "author": "Douglas Mayle", "author_id": 8458, "author_profile": "https://Stackoverflow.com/users/8458", "pm_score": 1, "selected": false, "text": "<pre><code>application/x-www-form-urlencoded\n</code></pre>\n\n<p>There's your answer. It's getting posted, you're ju...
2008/11/07
[ "https://Stackoverflow.com/questions/271043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34975/" ]
I'm using jQuery to post a form to a php file, simple script to verify user details. ``` var emailval = $("#email").val(); var invoiceIdval = $("#invoiceId").val(); $.post("includes/verify.php", {invoiceId:invoiceIdval , email:emailval }, function(data) { //stuff here. }); ``` PHP Code: `...
`$.post()` passes data to the underlying `$.ajax()` call, which sets `application/x-www-form-urlencoded` by default, so i don't think it's that. can you try this: ``` var post = $('#myForm').serialize(); $.post("includes/verify.php", post, function(data) { alert(data); }); ``` the `serialize()` call will ...
271,045
<p>I'm new to the MVC framework and wondering how to pass the RSS data from the controller to a view. I know there is a need to convert to an IEnumerable list of some sort. I have seen some examples of creating an anonymous type but can not figure out how to convert an RSS feed to a generic list and pass it to the view...
[ { "answer_id": 271484, "author": "Javier Suero Santos", "author_id": 34432, "author_profile": "https://Stackoverflow.com/users/34432", "pm_score": 0, "selected": false, "text": "<p>A rss is a xml file with special format. You may design a dataset with that generic format and read the rss...
2008/11/07
[ "https://Stackoverflow.com/questions/271045", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31148/" ]
I'm new to the MVC framework and wondering how to pass the RSS data from the controller to a view. I know there is a need to convert to an IEnumerable list of some sort. I have seen some examples of creating an anonymous type but can not figure out how to convert an RSS feed to a generic list and pass it to the view. ...
I've been playing around with a way of doing WebParts in MVC which are basically UserControls wrapped in a webPart container. One of my test UserControls is an Rss Feed control. I use the RenderAction HtmlHelper extension in the Futures dll to display it so a controller action is called. I use the SyndicationFeed class...
271,062
<p>I'm using Emgu.CV which is a C# wrapper for the OpenCV libraries. </p> <p>I changed the Emgu.CV source to invoke from the latest OpenCV library cv110.dll instead of cv100.dll and now I get this error (where ????? is cv110.dll). I have placed the cv110.dll file in all the same locations as the cv100.dll file however...
[ { "answer_id": 271484, "author": "Javier Suero Santos", "author_id": 34432, "author_profile": "https://Stackoverflow.com/users/34432", "pm_score": 0, "selected": false, "text": "<p>A rss is a xml file with special format. You may design a dataset with that generic format and read the rss...
2008/11/07
[ "https://Stackoverflow.com/questions/271062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31045/" ]
I'm using Emgu.CV which is a C# wrapper for the OpenCV libraries. I changed the Emgu.CV source to invoke from the latest OpenCV library cv110.dll instead of cv100.dll and now I get this error (where ????? is cv110.dll). I have placed the cv110.dll file in all the same locations as the cv100.dll file however this does...
I've been playing around with a way of doing WebParts in MVC which are basically UserControls wrapped in a webPart container. One of my test UserControls is an Rss Feed control. I use the RenderAction HtmlHelper extension in the Futures dll to display it so a controller action is called. I use the SyndicationFeed class...
271,067
<p>I have the following CSS and HTML snippet being rendered.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>textarea { border:1px solid #999999; width:100%; margin:...
[ { "answer_id": 271302, "author": "buti-oxa", "author_id": 2515, "author_profile": "https://Stackoverflow.com/users/2515", "pm_score": 2, "selected": false, "text": "<p>No, you cannot do that with CSS. That is the reason Microsoft initially introduced another, and maybe more practical <a ...
2008/11/07
[ "https://Stackoverflow.com/questions/271067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3957/" ]
I have the following CSS and HTML snippet being rendered. ```css textarea { border:1px solid #999999; width:100%; margin:5px 0; padding:3px; } ``` ```html <div style="display: block;" id="rulesformitem" class="formitem"> <label for="rules" id="ruleslabel">Rules:</label> <textarea cols="2" rows="10" id="ru...
Why not forget the hacks and just do it with CSS? One I use frequently: ```css .boxsizingBorder { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } ``` See browser support [here](http://caniuse.com/css3-boxsizing).
271,076
<p>Correct me if I am wrong,</p> <p>int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)<br> long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31)</p> <p>What is the difference in C++? Can they be used interchangeably?</p>
[ { "answer_id": 271083, "author": "Andru Luvisi", "author_id": 5922, "author_profile": "https://Stackoverflow.com/users/5922", "pm_score": 3, "selected": false, "text": "<p>It depends on your compiler. You are guaranteed that a long will be at least as large as an int, but you are not gu...
2008/11/07
[ "https://Stackoverflow.com/questions/271076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25632/" ]
Correct me if I am wrong, int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) What is the difference in C++? Can they be used interchangeably?
It is implementation dependent. For example, under Windows they are the same, but for example on Alpha systems a long was 64 bits whereas an int was 32 bits. This [article](http://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os) covers the rules for the Intel C++ compiler ...
271,077
<p>In my views.py, I'm building a list of two-tuples, where the second item in the tuple is another list, like this:</p> <pre><code>[ Product_Type_1, [ product_1, product_2 ], Product_Type_2, [ product_3, product_4 ]] </code></pre> <p>In plain old Python, I could iteration the list like this:</p> <pre><code>for pr...
[ { "answer_id": 271098, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 2, "selected": false, "text": "<p>Just send the template a list of product types and do something like:</p>\n\n<pre><code>{% for product_type in pr...
2008/11/07
[ "https://Stackoverflow.com/questions/271077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21245/" ]
In my views.py, I'm building a list of two-tuples, where the second item in the tuple is another list, like this: ``` [ Product_Type_1, [ product_1, product_2 ], Product_Type_2, [ product_3, product_4 ]] ``` In plain old Python, I could iteration the list like this: ``` for product_type, products in list: pri...
it would be best if you construct your data like {note the '(' and ')' can be exchanged for '[' and ']' repectively, one being for tuples, one for lists} ``` [ (Product_Type_1, ( product_1, product_2 )), (Product_Type_2, ( product_3, product_4 )) ] ``` and have the template do this: ``` {% for product_type, prod...
271,090
<p>Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server <b>without</b> using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file.</p> <p>The reason it has to be that way is that I would like to backup my files to...
[ { "answer_id": 271100, "author": "vfilby", "author_id": 24279, "author_profile": "https://Stackoverflow.com/users/24279", "pm_score": 1, "selected": false, "text": "<p>Rather than passing your password use a public/private key system. Add the public key for a machine to the authorized k...
2008/11/07
[ "https://Stackoverflow.com/questions/271090", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11688/" ]
Is there a way to pass a password to ssh automatically. I would like to automatically ssh to a server **without** using public key authentication or expect scripts, by somehow getting ssh to read the password from stdin or a file. The reason it has to be that way is that I would like to backup my files to a server usi...
Use `sshpass`. For example, when password is in `password.txt` file: ``` sshpass -fpassword.txt ssh username@hostname ``` (taken from the answer to a [similar question](https://stackoverflow.com/q/13298487/441652))
271,106
<p>I am trying to get this program to give me an out put that when I do an addition, subtraction, multiplication, or division problem it will give me the answer. However, it is not working can anyone help.</p> <pre><code>int main () { int choice; float a, b; float sum; float difference; float product...
[ { "answer_id": 271119, "author": "bog", "author_id": 20909, "author_profile": "https://Stackoverflow.com/users/20909", "pm_score": 1, "selected": false, "text": "<p>You've misspelled quotient.</p>\n\n<p>Actually, don't pass the address of your args to printf. You only need to do that fo...
2008/11/07
[ "https://Stackoverflow.com/questions/271106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am trying to get this program to give me an out put that when I do an addition, subtraction, multiplication, or division problem it will give me the answer. However, it is not working can anyone help. ``` int main () { int choice; float a, b; float sum; float difference; float product; float quot...
What are you trying to accomplish with this line? ``` scanf("%f %f %f %f", &sum, &difference, &product, &quotiont); ``` What this does is takes four numbers from the user and loads them into the four variables, respectively. Right after this line you assign new values to these four variables, so there is no point ...
271,109
<p>I have a simple question. Is there a way ( using reflections I suppose ) to iterate all the static values of a class?</p> <p>For instance </p> <pre><code>class Any { static int one = 1; static int two = 2; static int three = 3; public static void main( String [] args ) { for( int i : mag...
[ { "answer_id": 271127, "author": "OscarRyz", "author_id": 20654, "author_profile": "https://Stackoverflow.com/users/20654", "pm_score": 2, "selected": false, "text": "<p>Hey.. it was very easy. :P </p>\n\n<pre><code> Field [] constants = Main.class.getFields();\n Object some =...
2008/11/07
[ "https://Stackoverflow.com/questions/271109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
I have a simple question. Is there a way ( using reflections I suppose ) to iterate all the static values of a class? For instance ``` class Any { static int one = 1; static int two = 2; static int three = 3; public static void main( String [] args ) { for( int i : magicMethod( Any.class )...
``` import java.util.*; import java.lang.reflect.*; class Any { static int one = 1; static int two = 2; static int three = 3; public static void main( String [] args ) { for( int i : magicMethod( Any.class ) ){ System.out.println( i ); } } public static Integ...
271,145
<p>Given a UTC time string like this:</p> <pre><code>2005-11-01T00:00:00-04:00 </code></pre> <p>What is the best way to convert it to a DateTime using a Crystal Reports formula?</p> <p>My best solution is posted below.</p> <p>I hope someone out there can blow me away with a one-liner...</p>
[ { "answer_id": 271147, "author": "JosephStyons", "author_id": 672, "author_profile": "https://Stackoverflow.com/users/672", "pm_score": 1, "selected": false, "text": "<p>Here is my best solution, with comments:</p>\n\n<pre><code>//assume a date stored as a string in this format:\n//2005-...
2008/11/07
[ "https://Stackoverflow.com/questions/271145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/672/" ]
Given a UTC time string like this: ``` 2005-11-01T00:00:00-04:00 ``` What is the best way to convert it to a DateTime using a Crystal Reports formula? My best solution is posted below. I hope someone out there can blow me away with a one-liner...
Here you go: ``` CDateTime(CDate(Split({?UTCDateString}, "T")[1]) , CTime(Split(Split({?UTCDateString}, "T")[2], "-")[1])) ```
271,149
<p>how do i check if an item is selected or not in my listbox? so i have a button remove, but i only want that button to execute if an item is selected in the list box. im using asp.net code behind C#. I'd prefer if this validation occurred on the server side.</p> <p>cheers..</p>
[ { "answer_id": 271164, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>On the callback for the button click, just check if the selected index of the list box is greater than or equal to z...
2008/11/07
[ "https://Stackoverflow.com/questions/271149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
how do i check if an item is selected or not in my listbox? so i have a button remove, but i only want that button to execute if an item is selected in the list box. im using asp.net code behind C#. I'd prefer if this validation occurred on the server side. cheers..
``` for (int i = 0; i < lbSrc.Items.Count; i++) { if (lbSrc.Items[i].Selected == true) { lbSrc.Items.RemoveAt(lbSrc.SelectedIndex); } } ``` this is what i came up with.
271,171
<p>This is a little confusing to explain, so bear with me here...</p> <p>I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the bo...
[ { "answer_id": 271172, "author": "nickf", "author_id": 9021, "author_profile": "https://Stackoverflow.com/users/9021", "pm_score": 8, "selected": true, "text": "<p>The way I'm doing it now is basically like this:</p>\n<p>The HTML:</p>\n<pre><code>&lt;textarea id=&quot;myText&quot;&gt;\n ...
2008/11/07
[ "https://Stackoverflow.com/questions/271171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
This is a little confusing to explain, so bear with me here... I want to set up a system where a user can send templated emails via my website, except it's not actually sent using my server - it instead just opens up their own local mail client with an email ready to go. The application would fill out the body of the ...
The way I'm doing it now is basically like this: The HTML: ``` <textarea id="myText"> Lorem ipsum... </textarea> <button onclick="sendMail(); return false">Send</button> ``` The Javascript: ``` function sendMail() { var link = "mailto:me@example.com" + "?cc=myCCaddress@example.com" ...
271,198
<p>One of the frequent causes of memory leaks in .Net are event handlers which are never removed from their source objects. </p> <p>Will this WCF code cause a memory leak, or will the lambda go out of scope too, allowing both the proxy class and the handler to be GCed?</p> <pre><code>void AMethod() { WCFClient pr...
[ { "answer_id": 271232, "author": "Timothy Khouri", "author_id": 11917, "author_profile": "https://Stackoverflow.com/users/11917", "pm_score": -1, "selected": false, "text": "<p>That object will die... it'll be cleaned up.</p>\n\n<p>Don't forget that the lamda isn't doing anything special...
2008/11/07
[ "https://Stackoverflow.com/questions/271198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25201/" ]
One of the frequent causes of memory leaks in .Net are event handlers which are never removed from their source objects. Will this WCF code cause a memory leak, or will the lambda go out of scope too, allowing both the proxy class and the handler to be GCed? ``` void AMethod() { WCFClient proxy; proxy = new ...
Here's my test - note the explicit `proxy` set to `null` in the lambda - without it the `WeakReference` lives and therefore a leak is likely: ``` public class Proxy { private bool _isOpen; public event EventHandler Complete; public void Close() { _isOpen = false; } public void Open(...
271,204
<p>This loop is slower than I would expect, and I'm not sure where yet. See anything?</p> <p>I'm reading an Accces DB, using client-side cursors. When I have 127,000 rows with 20 columns, this loop takes about 10 seconds. The 20 columns are string, int, and date types. All the types get converted to ANSI string...
[ { "answer_id": 271230, "author": "CVertex", "author_id": 209, "author_profile": "https://Stackoverflow.com/users/209", "pm_score": 2, "selected": false, "text": "<p>I can't tell from looking at your code, someone more familiar with COM/ATL may have a better answer.</p>\n\n<p>By trial n e...
2008/11/07
[ "https://Stackoverflow.com/questions/271204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9328/" ]
This loop is slower than I would expect, and I'm not sure where yet. See anything? I'm reading an Accces DB, using client-side cursors. When I have 127,000 rows with 20 columns, this loop takes about 10 seconds. The 20 columns are string, int, and date types. All the types get converted to ANSI strings before they are...
Try commenting out the code in the for loop and comparing the time. Once you have a reading, start uncommenting various sections until you hit the bottle-neck.
271,210
<p>I have a build server running CruiseControl.NET. It works well for the 7 projects that are configured to run on that server (let's call it server A).</p> <p>Now I have a new project that I wish to build on a different server (server B), but I want it to appear in the same ccnet dashboard as the existing projects. <...
[ { "answer_id": 271858, "author": "John Lemp", "author_id": 12915, "author_profile": "https://Stackoverflow.com/users/12915", "pm_score": 4, "selected": true, "text": "<p>In <code>dashboard.config</code> (default location is <code>c:\\Program Files\\CruiseControl.NET\\webdashboard\\dashbo...
2008/11/07
[ "https://Stackoverflow.com/questions/271210", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30183/" ]
I have a build server running CruiseControl.NET. It works well for the 7 projects that are configured to run on that server (let's call it server A). Now I have a new project that I wish to build on a different server (server B), but I want it to appear in the same ccnet dashboard as the existing projects. How do I ...
In `dashboard.config` (default location is `c:\Program Files\CruiseControl.NET\webdashboard\dashboard.config`) take a look at the [Servers Configuration Block](http://confluence.public.thoughtworks.org/display/CCNET/Servers+Configuration+Block): ``` <servers> <server name="local" url="tcp://localhost:21234/C...
271,218
<p>I am trying something very simple, but for some reason it does not work. Basically, I need to rename some nodes in an XML document. Thus, I created an XSLT file to do the transformation.</p> <p>Here is an example of the XML:</p> <p>EDIT: Addresses and Address elements occur at many levels. This is what caused me t...
[ { "answer_id": 271301, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "<h2>Why might an XSLT fail?</h2>\n\n<p>An XSLT will fail because of obvious things like typos. However, the most likely ...
2008/11/07
[ "https://Stackoverflow.com/questions/271218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10224/" ]
I am trying something very simple, but for some reason it does not work. Basically, I need to rename some nodes in an XML document. Thus, I created an XSLT file to do the transformation. Here is an example of the XML: EDIT: Addresses and Address elements occur at many levels. This is what caused me to have to try and...
Why might an XSLT fail? ----------------------- An XSLT will fail because of obvious things like typos. However, the most likely situation relates to namespace usage. If you declared a default namespace for your XML but don't include that in your XSLT, the XSLT won't match the templates as you might expect. The follo...
271,224
<p>Can anyone reccomend a .net control (winforms) that can be used to as a designer to edit xml files / DSL files ??</p>
[ { "answer_id": 271301, "author": "Jeff Yates", "author_id": 23234, "author_profile": "https://Stackoverflow.com/users/23234", "pm_score": 4, "selected": true, "text": "<h2>Why might an XSLT fail?</h2>\n\n<p>An XSLT will fail because of obvious things like typos. However, the most likely ...
2008/11/07
[ "https://Stackoverflow.com/questions/271224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Can anyone reccomend a .net control (winforms) that can be used to as a designer to edit xml files / DSL files ??
Why might an XSLT fail? ----------------------- An XSLT will fail because of obvious things like typos. However, the most likely situation relates to namespace usage. If you declared a default namespace for your XML but don't include that in your XSLT, the XSLT won't match the templates as you might expect. The follo...
271,238
<p>I'm just concerned about Windows, so there's no need to go into esoterica about Mono compatibility or anything like that.</p> <p>I should also add that the app that I'm writing is WPF, and I'd prefer to avoid taking a dependency on <code>System.Windows.Forms</code> if at all possible.</p>
[ { "answer_id": 271249, "author": "ine", "author_id": 4965, "author_profile": "https://Stackoverflow.com/users/4965", "pm_score": 1, "selected": false, "text": "<p>The simplest way would be to create an Autoplay Handler:</p>\n\n<p><a href=\"http://www.codeproject.com/KB/system/AutoplayDem...
2008/11/07
[ "https://Stackoverflow.com/questions/271238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26628/" ]
I'm just concerned about Windows, so there's no need to go into esoterica about Mono compatibility or anything like that. I should also add that the app that I'm writing is WPF, and I'd prefer to avoid taking a dependency on `System.Windows.Forms` if at all possible.
Give this a shot... ``` using System; using System.Collections.Generic; using System.Text; using System.Management; namespace WMITestConsolApplication { class Program { static void Main(string[] args) { AddInsertUSBHandler(); AddRemoveUSBHandler(); while ...
271,244
<p>Given a Django.db models class:</p> <pre><code>class P(models.Model): type = models.ForeignKey(Type) # Type is another models.Model class name = models.CharField() </code></pre> <p>where one wishes to create a new P with a specified type, i.e. how does one make "type" to be a default, hidden field (from the ...
[ { "answer_id": 271252, "author": "Harley Holcombe", "author_id": 1057, "author_profile": "https://Stackoverflow.com/users/1057", "pm_score": 3, "selected": false, "text": "<p>To have a default Foreign Key in a model:</p>\n\n<pre><code>mydefault = Type.objects.get(pk=3)\n\nclass P(models....
2008/11/07
[ "https://Stackoverflow.com/questions/271244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19212/" ]
Given a Django.db models class: ``` class P(models.Model): type = models.ForeignKey(Type) # Type is another models.Model class name = models.CharField() ``` where one wishes to create a new P with a specified type, i.e. how does one make "type" to be a default, hidden field (from the user), where type is given...
To have a default Foreign Key in a model: ``` mydefault = Type.objects.get(pk=3) class P(models.Model): type = models.ForeignKey(Type, default=mydefault) # Type is another models.Model class name = models.CharField() ``` Note that using `pk=x` is pretty ugly, as ideally you shouldn't care what the primary key...
271,260
<p>I was in need of a way to compress images in .net so i looked into using the .net GZipStream class (or DeflateStream). However i found that decompression was not always successful, sometimes the images would decompress fine and other times i would get a GDI+ error that something is corrupted.</p> <p>After investiga...
[ { "answer_id": 271264, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 7, "selected": true, "text": "<p>You need to <code>Close()</code> the <code>ZipStream</code> after adding all the data you want to compress; it reta...
2008/11/07
[ "https://Stackoverflow.com/questions/271260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35371/" ]
I was in need of a way to compress images in .net so i looked into using the .net GZipStream class (or DeflateStream). However i found that decompression was not always successful, sometimes the images would decompress fine and other times i would get a GDI+ error that something is corrupted. After investigating the i...
You need to `Close()` the `ZipStream` after adding all the data you want to compress; it retains a buffer of unwritten bytes internally (even if you `Flush()`) that needs to be written. More generally, `Stream` is `IDisposable`, so you should also be `using` each... (yes, I know that `MemoryStream` isn't going to lose...
271,265
<p>I'm using JMX to save some diagnostic information from a remote process. Looking at the interface in jconsole shows that the return type is <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/management/openmbean/CompositeData.html" rel="noreferrer">CompositeData</a> (the data actually comes back as <a href="http...
[ { "answer_id": 271400, "author": "Tyler Levine", "author_id": 35339, "author_profile": "https://Stackoverflow.com/users/35339", "pm_score": 4, "selected": true, "text": "<p>If I'm not mistaken you could do</p>\n\n<pre><code>Set&lt; String &gt; keys = cData.getCompositeType().keySet();\n<...
2008/11/07
[ "https://Stackoverflow.com/questions/271265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18437/" ]
I'm using JMX to save some diagnostic information from a remote process. Looking at the interface in jconsole shows that the return type is [CompositeData](http://java.sun.com/j2se/1.5.0/docs/api/javax/management/openmbean/CompositeData.html) (the data actually comes back as [CompositeDataSupport](http://java.sun.com/j...
If I'm not mistaken you could do ``` Set< String > keys = cData.getCompositeType().keySet(); ``` (given that cData is a CompositeData object) <http://java.sun.com/j2se/1.5.0/docs/api/javax/management/openmbean/CompositeType.html#keySet()>
271,273
<p>I'm trying to take advantage of the constant memory, but I'm having a hard time figuring out how to nest arrays. What I have is an array of data that has counts for internal data but those are different for each entry. So based around the following simplified code I have two problems. First I don't know how to al...
[ { "answer_id": 672941, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Why don't you just use the so-called \"packed\" data representation? This approach allows you to place all the data you nee...
2008/11/07
[ "https://Stackoverflow.com/questions/271273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35373/" ]
I'm trying to take advantage of the constant memory, but I'm having a hard time figuring out how to nest arrays. What I have is an array of data that has counts for internal data but those are different for each entry. So based around the following simplified code I have two problems. First I don't know how to allocate...
I think constant memory is 64K and you cannot allocate it dynamically using `cudaMalloc`. It has to be declared constant, say, ``` __constant__ data mydata[100]; ``` Similarly you also don't need to free it. Also, you shouldn't pass the reference to it via pointer, just access it as a global variable. I tried doing ...
271,274
<p>I am adding objects into a java Vector using its add(Object) method. In my example, the first 5 objects are identical, followed by 2 instances different from the first five. For some reasons, as soon as I insert the first one that is different, it changes the entire vector to that value!</p> <p>'values' is an itera...
[ { "answer_id": 271293, "author": "erickson", "author_id": 3474, "author_profile": "https://Stackoverflow.com/users/3474", "pm_score": 3, "selected": false, "text": "<p>I suspect that, somehow, the \"objects\" you are getting from the iterator are really multiple references to a single in...
2008/11/07
[ "https://Stackoverflow.com/questions/271274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25645/" ]
I am adding objects into a java Vector using its add(Object) method. In my example, the first 5 objects are identical, followed by 2 instances different from the first five. For some reasons, as soon as I insert the first one that is different, it changes the entire vector to that value! 'values' is an iterator contai...
I suspect that, somehow, the "objects" you are getting from the iterator are really multiple references to a single instance of a mutable object, which is changing its state from "1" to "2". The thing I can't guess at is how it's changing state in this apparently single-threaded operation. Can you post more complete c...
271,285
<p>My webapp (ASP.NET 2.0) consumes a webservice (asmx on 1.1 framework) on the same machine. After getting XML in return, I pass it to <code>XslCompiledTransform</code> for transform XML to HTML and it works fine.</p> <p>Yesterday I got a <code>System.IO.FileNotFoundException</code> frequently and don't know what c...
[ { "answer_id": 271304, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 1, "selected": false, "text": "<p>OK, that's an interesting one. I've seen similar issues with serializers, but not with <code>XslCompiledTransform<...
2008/11/07
[ "https://Stackoverflow.com/questions/271285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35682/" ]
My webapp (ASP.NET 2.0) consumes a webservice (asmx on 1.1 framework) on the same machine. After getting XML in return, I pass it to `XslCompiledTransform` for transform XML to HTML and it works fine. Yesterday I got a `System.IO.FileNotFoundException` frequently and don't know what causes this kind of problem. Fir...
After checking for details and googling for the related topics, 1. This problem found with .Transform() and also occures with XmlSerialization as Marc said. Christoph Schittko has a good article for [troubleshooting](http://msdn.microsoft.com/en-us/library/aa302290.aspx). 2. Someone said the problem may because some u...
271,319
<p>Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed.</p> <p>Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for...
[ { "answer_id": 271322, "author": "Christian C. Salvadó", "author_id": 5445, "author_profile": "https://Stackoverflow.com/users/5445", "pm_score": 5, "selected": false, "text": "<p>Check <a href=\"http://www.sqlite.org/\" rel=\"noreferrer\">SQLite</a>, it's a software library that impleme...
2008/11/07
[ "https://Stackoverflow.com/questions/271319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11256/" ]
Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed. Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for any alter...
Depends on what you mean by lightweight. Easy on Ram? Or lighter db file? Or lighter connector to connect to db? Or fewer files over all? I'll give a comparison of what I know: ``` no of files cumulative size of files db size Firebird 2.5 5 6.82 MB 25...
271,330
<p>I use <a href="http://docs.jquery.com/Plugins/Treeview" rel="nofollow noreferrer">jquery tree plugin</a> to render hierarchical data. </p> <p>I have coded additional functions which would allow user to interact with this data (like adding/deleting nodes, swapping nodes, etc...)</p> <p>Currently this plugin support...
[ { "answer_id": 271382, "author": "jatanp", "author_id": 959, "author_profile": "https://Stackoverflow.com/users/959", "pm_score": 1, "selected": false, "text": "<p>I found some workaround as given below,</p>\n\n<p>Once the node is swapped up, virtually add its previous node to its child,...
2008/11/07
[ "https://Stackoverflow.com/questions/271330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959/" ]
I use [jquery tree plugin](http://docs.jquery.com/Plugins/Treeview) to render hierarchical data. I have coded additional functions which would allow user to interact with this data (like adding/deleting nodes, swapping nodes, etc...) Currently this plugin supports that whenever you want to add any node, you can call...
I found some workaround as given below, Once the node is swapped up, virtually add its previous node to its child, $("#browser").treeview({add:$("#topnd2").insertBefore(previous).next()}); If node is swapped down, virtuall add the current node to its next node. $("#browser").treeview({add:$("#topnd2").insertAfter(n...
271,340
<p>I'm trying to use a dojo combobox with an Ajax data source. What I have is </p> <pre><code>&lt;div dojoType="dojo.data.ItemFileReadStore" jsId="tags" url="&lt;%=ResolveClientUrl("~/Tag/TagMatches")%&gt;" &gt; &lt;/div&gt; &lt;select dojoType="dijit.form.ComboBox" store="tags" value=""...
[ { "answer_id": 271443, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": true, "text": "<p>If I understand you correctly, you want the client to load different set of data from the server based on some general c...
2008/11/07
[ "https://Stackoverflow.com/questions/271340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/361/" ]
I'm trying to use a dojo combobox with an Ajax data source. What I have is ``` <div dojoType="dojo.data.ItemFileReadStore" jsId="tags" url="<%=ResolveClientUrl("~/Tag/TagMatches")%>" > </div> <select dojoType="dijit.form.ComboBox" store="tags" value="" name="tagName"> </select> ...
If I understand you correctly, you want the client to load different set of data from the server based on some general condition defined elsewhere. Basically there is no need to have a `<div>` pre-defined. You can also create the `ItemFileReadStore` directly in JavaScript: earlier...: ``` var tagMatchUrlBase = '<%=R...
271,347
<p>I have a class that stores a serialized value and a type. I want to have a property/method returning the value already casted:</p> <pre><code>public String Value { get; set; } public Type TheType { get; set; } public typeof(TheType) CastedValue { get { return Convert.ChangeType(Value, typeof(_Type)); } </code></p...
[ { "answer_id": 271356, "author": "Brannon", "author_id": 5745, "author_profile": "https://Stackoverflow.com/users/5745", "pm_score": 7, "selected": false, "text": "<p>It's possible if the class containing the property is generic, and you declare the property using the generic parameter:<...
2008/11/07
[ "https://Stackoverflow.com/questions/271347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a class that stores a serialized value and a type. I want to have a property/method returning the value already casted: ``` public String Value { get; set; } public Type TheType { get; set; } public typeof(TheType) CastedValue { get { return Convert.ChangeType(Value, typeof(_Type)); } ``` Is this possible i...
It's possible if the class containing the property is generic, and you declare the property using the generic parameter: ``` class Foo<TValue> { public string Value { get; set; } public TValue TypedValue { get { return (TValue)Convert.ChangeType(Value, typeof(TValue)); } } } ``...
271,364
<p><code>:vimgrep</code> looks like a really useful thing.</p> <p>Here's how to use it:</p> <pre><code>:vim[grep][!] /{pattern}/[g][j] {file} ... </code></pre> <p><code>:help</code> says that you can essentially glob <code>{file}</code> to name, say, <code>*.c</code> for the current directory. I may have started Vi...
[ { "answer_id": 271381, "author": "Jerub", "author_id": 14648, "author_profile": "https://Stackoverflow.com/users/14648", "pm_score": 3, "selected": false, "text": "<p>You can do this:</p>\n\n<pre><code>:bufdo vimgrep /pattern/ %\n</code></pre>\n\n<p>% substitutes the buffer name.</p>\n" ...
2008/11/07
[ "https://Stackoverflow.com/questions/271364", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35221/" ]
`:vimgrep` looks like a really useful thing. Here's how to use it: ``` :vim[grep][!] /{pattern}/[g][j] {file} ... ``` `:help` says that you can essentially glob `{file}` to name, say, `*.c` for the current directory. I may have started Vim with a list of files that is complicated enough that I don't want to manual...
Can't you catch the result in these commands into a register (`:h :redir`), and insert it back into `:vimgrep` call (with a `:exe`). Something like: ``` :exe "vimgrep/pattern/ " . lh#askvim#Exe(':args') ``` Notes: * [lh#askvim#Exe](https://github.com/LucHermitte/lh-vim-lib#miscellaneous-functions) is just a wrappe...
271,380
<p>One of the files in my current head revision got corrupted. I want to make an older revision of that file the head revision as usually people sync to head revsion in my project. How to do that?</p>
[ { "answer_id": 271387, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 7, "selected": true, "text": "<p>You should revert all changes since that old reversion. In principle,</p>\n\n<pre><code>svn merge -rHEAD:oldrev ...
2008/11/07
[ "https://Stackoverflow.com/questions/271380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13440/" ]
One of the files in my current head revision got corrupted. I want to make an older revision of that file the head revision as usually people sync to head revsion in my project. How to do that?
You should revert all changes since that old reversion. In principle, ``` svn merge -rHEAD:oldrev filename svn commit -m "rolled back to oldrev" ``` should do. The later revisions are still there, but reverted.
271,394
<p>A class I am taking currently requires us to do all of our coding in smalltalk (it's a Design class). On one of our projects, I am looking to do some things, and am having a tough time finding how to do them. It seems that what most people do is modify their own version of smalltalk to do what they need it to do. I ...
[ { "answer_id": 271402, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 4, "selected": true, "text": "<p>The problem is that</p>\n\n<pre><code> (expr) and: (expr) ifTrue: aBlock\n</code></pre>\n\n<p>is parsed as the m...
2008/11/07
[ "https://Stackoverflow.com/questions/271394", "https://Stackoverflow.com", "https://Stackoverflow.com/users/50/" ]
A class I am taking currently requires us to do all of our coding in smalltalk (it's a Design class). On one of our projects, I am looking to do some things, and am having a tough time finding how to do them. It seems that what most people do is modify their own version of smalltalk to do what they need it to do. I am ...
The problem is that ``` (expr) and: (expr) ifTrue: aBlock ``` is parsed as the method `and:ifTrue:` If you look at the Boolean class (and either True or False in particular), you notice that ifTrue: is just a regular method, and that no method and:ifTrue: exists - however, plain and: does. So to make it clear that ...
271,398
<p>Let's make a list of answers where you post your excellent and favorite <a href="http://en.wikipedia.org/wiki/Extension_method" rel="nofollow noreferrer">extension methods</a>. </p> <p>The requirement is that the full code must be posted and a example and an explanation on how to use it.</p> <p>Based on the high i...
[ { "answer_id": 271409, "author": "bovium", "author_id": 11135, "author_profile": "https://Stackoverflow.com/users/11135", "pm_score": 5, "selected": false, "text": "<p>The ThrowIfArgumentIsNull is a nice way to do that null check we all should do.</p>\n\n<pre><code>public static class Ex...
2008/11/07
[ "https://Stackoverflow.com/questions/271398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11135/" ]
Let's make a list of answers where you post your excellent and favorite [extension methods](http://en.wikipedia.org/wiki/Extension_method). The requirement is that the full code must be posted and a example and an explanation on how to use it. Based on the high interest in this topic I have setup an Open Source Proj...
``` public static bool In<T>(this T source, params T[] list) { if(null==source) throw new ArgumentNullException("source"); return list.Contains(source); } ``` Allows me to replace: ``` if(reallyLongIntegerVariableName == 1 || reallyLongIntegerVariableName == 6 || reallyLongIntegerVariableName == 9 || ...
271,406
<p>I have a table in lua with some data.</p> <pre><code>sometable = { {name = "bob", something = "foo"}, {name = "greg", something = "bar"} } </code></pre> <p>I then want to loop through the table and assign a number to each name as a variable. New to lua and tried it like this.</p> <pre><code>for i,t in ip...
[ { "answer_id": 271413, "author": "Tyler Levine", "author_id": 35339, "author_profile": "https://Stackoverflow.com/users/35339", "pm_score": -1, "selected": false, "text": "<p>The <a href=\"http://www.lua.org/manual/5.1/manual.html#5.1\" rel=\"nofollow noreferrer\">ipairs</a> function wil...
2008/11/07
[ "https://Stackoverflow.com/questions/271406", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18933/" ]
I have a table in lua with some data. ``` sometable = { {name = "bob", something = "foo"}, {name = "greg", something = "bar"} } ``` I then want to loop through the table and assign a number to each name as a variable. New to lua and tried it like this. ``` for i,t in ipairs(sometable) do t.name = i end...
```lua > sometable = {{name = "bob", something = "foo"},{name = "greg", something = "bar"}} > for i,t in ipairs(sometable) do t[t.name] = i end > for i,t in ipairs(sometable) do for j,u in pairs (t) do print (j,u) end end name bob something foo bob 1 greg 2 something bar name greg > return sometable[1].bob 1...
271,428
<hr> <p>Thanks for answers,Actually I am not puzzled about draw 1024*768 pixels is slower than 100* 100 pixels... It is so simple a logic.. Which made me puzzled is that DrawImage's interpolation algorithm may be very slow, while there exists lots of better algorithm, and its decoder seems can decode from a jpg with a...
[ { "answer_id": 271463, "author": "Johann Gerell", "author_id": 6345, "author_profile": "https://Stackoverflow.com/users/6345", "pm_score": 3, "selected": false, "text": "<p>So, what you're really wondering is why</p>\n\n<pre><code>graphics.DrawImage(bitmap,0,0,200,200);\n</code></pre>\n\...
2008/11/07
[ "https://Stackoverflow.com/questions/271428", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25749/" ]
--- Thanks for answers,Actually I am not puzzled about draw 1024\*768 pixels is slower than 100\* 100 pixels... It is so simple a logic.. Which made me puzzled is that DrawImage's interpolation algorithm may be very slow, while there exists lots of better algorithm, and its decoder seems can decode from a jpg with a c...
You don't need to decode JPGs if you're scaling down by a factor of 8. JPG images consist of blocks of 8 by 8 pixels, DCT-transformed. The average value of this block is the 0,0 coefficient of the DCT. So, scaling down a factor of 8 is merely a matter of throwing away all other components. Scaling down even further (eg...
271,440
<p>I met an interesting issue about C#. I have code like below.</p> <pre><code>List&lt;Func&lt;int&gt;&gt; actions = new List&lt;Func&lt;int&gt;&gt;(); int variable = 0; while (variable &lt; 5) { actions.Add(() =&gt; variable * 2); ++ variable; } foreach (var act in actions) { Console.WriteLine(act.Invok...
[ { "answer_id": 271447, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 9, "selected": true, "text": "<p>Yes - take a copy of the variable inside the loop:</p>\n\n<pre><code>while (variable &lt; 5)\n{\n int copy = variab...
2008/11/07
[ "https://Stackoverflow.com/questions/271440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26349/" ]
I met an interesting issue about C#. I have code like below. ``` List<Func<int>> actions = new List<Func<int>>(); int variable = 0; while (variable < 5) { actions.Add(() => variable * 2); ++ variable; } foreach (var act in actions) { Console.WriteLine(act.Invoke()); } ``` I expect it to output 0, 2, 4,...
Yes - take a copy of the variable inside the loop: ``` while (variable < 5) { int copy = variable; actions.Add(() => copy * 2); ++ variable; } ``` You can think of it as if the C# compiler creates a "new" local variable every time it hits the variable declaration. In fact it'll create appropriate new clo...
271,464
<p>I have a multiline text string (e.g. "Stuff\nMore Stuff\nYet More Stuff"), and I want to paint it, along with a bitmap into a tooltip. Since I am painting the bitmap, I need to set OwnerDraw to true, which I am doing. I am also handling the Popup event, so I can size the tooltip to be large enough to hold the text ...
[ { "answer_id": 271628, "author": "Robert Jeppesen", "author_id": 9436, "author_profile": "https://Stackoverflow.com/users/9436", "pm_score": 3, "selected": true, "text": "<p>I assume that if you define the bounding rectangle to draw in (calculating the image offset yourself) you could ju...
2008/11/07
[ "https://Stackoverflow.com/questions/271464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2683/" ]
I have a multiline text string (e.g. "Stuff\nMore Stuff\nYet More Stuff"), and I want to paint it, along with a bitmap into a tooltip. Since I am painting the bitmap, I need to set OwnerDraw to true, which I am doing. I am also handling the Popup event, so I can size the tooltip to be large enough to hold the text and ...
I assume that if you define the bounding rectangle to draw in (calculating the image offset yourself) you could just: ``` RectangleF rect = new RectangleF(100,100,100,100); e.Graphics.DrawString(myString, myFont, myBrush, rect); ```
271,485
<p>whats the best way to export a Datagrid to excel? I have no experience whatsoever in exporting datagrid to excel, so i want to know how you guys export datagrid to excel. i read that there are a lot of ways, but i am thinking to just make a simple export excel to datagrid function.i am using asp.net C#</p> <p>cheer...
[ { "answer_id": 271487, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 4, "selected": true, "text": "<p>The simplest way is to simply write either csv, or html (in particular, a <code>&lt;table&gt;&lt;tr&gt;&lt;td&gt;.....
2008/11/07
[ "https://Stackoverflow.com/questions/271485", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23491/" ]
whats the best way to export a Datagrid to excel? I have no experience whatsoever in exporting datagrid to excel, so i want to know how you guys export datagrid to excel. i read that there are a lot of ways, but i am thinking to just make a simple export excel to datagrid function.i am using asp.net C# cheers..
The simplest way is to simply write either csv, or html (in particular, a `<table><tr><td>...</td></tr>...</table>`) to the output, and simply pretend that it is in excel format via the content-type header. Excel will happily load either; csv is simpler... Here's a similar example (it actually takes an IEnumerable, bu...
271,488
<p>I asked <a href="https://stackoverflow.com/questions/269417/which-language-should-i-use">a question</a> earlier about which language to use for an AI prototype. The consensus seemed to be that if I want it to be fast, I need to use a language like Java or C++, but that Python / Perl / Ruby would be good for the inte...
[ { "answer_id": 271494, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 2, "selected": false, "text": "<p>It may be a good approach to start with a script, and call a compilation-based language from that script only for more advan...
2008/11/07
[ "https://Stackoverflow.com/questions/271488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11522/" ]
I asked [a question](https://stackoverflow.com/questions/269417/which-language-should-i-use) earlier about which language to use for an AI prototype. The consensus seemed to be that if I want it to be fast, I need to use a language like Java or C++, but that Python / Perl / Ruby would be good for the interface bits. ...
[Boost.Python](http://www.boost.org/doc/libs/1_36_0/libs/python/doc/tutorial/doc/html/index.html) provides an easy way to turn C++ code into Python modules. It's rather mature and works well in my experience. For example, the inevitable Hello World... ``` char const* greet() { return "hello, world"; } ``` can be...
271,518
<p>I am using axis 2 webservice client.</p> <p>The first https call to the webservice throws a exception with the message: "Message did not contain a valid Security Element".</p> <p>I think that the problem could be the security mode: maybe it has to be message level security. In this case, how can I configure it in ...
[ { "answer_id": 354882, "author": "Matt Campbell", "author_id": 41895, "author_profile": "https://Stackoverflow.com/users/41895", "pm_score": 1, "selected": false, "text": "<p>If you don't mind using EXT-GWT, a much prettier fully compliant GWT UI toolkit then this might be more what your...
2008/11/07
[ "https://Stackoverflow.com/questions/271518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29600/" ]
I am using axis 2 webservice client. The first https call to the webservice throws a exception with the message: "Message did not contain a valid Security Element". I think that the problem could be the security mode: maybe it has to be message level security. In this case, how can I configure it in axis?. The code:...
If you don't mind using EXT-GWT, a much prettier fully compliant GWT UI toolkit then this might be more what your looking for. [The Example](http://extjs.com/examples/layouts/accordionlayout.html). GXT as it is also called can do lots of good things for a GUI.
271,520
<p>I could do this in C#..</p> <pre><code>int number = 2; string str = "Hello " + number + " world"; </code></pre> <p>..and str ends up as "Hello 2 world".</p> <p>In VB.NET i could do this..</p> <pre><code>Dim number As Integer = 2 Dim str As String = "Hello " + number + " world" </code></pre> <p>..but I get an In...
[ { "answer_id": 271529, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 5, "selected": true, "text": "<p>In VB I believe the string concatenation operator is &amp; rather than + so try this:</p>\n\n<pre><code>Dim number As ...
2008/11/07
[ "https://Stackoverflow.com/questions/271520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15233/" ]
I could do this in C#.. ``` int number = 2; string str = "Hello " + number + " world"; ``` ..and str ends up as "Hello 2 world". In VB.NET i could do this.. ``` Dim number As Integer = 2 Dim str As String = "Hello " + number + " world" ``` ..but I get an InvalidCastException "Conversion from string "Hello " to t...
In VB I believe the string concatenation operator is & rather than + so try this: ``` Dim number As Integer = 2 Dim str As String = "Hello " & number & " world" ``` Basically when VB sees + I suspect it tries do numeric addition or use the addition operator defined in a type (or no doubt other more complicated thing...
271,526
<p>I use <code>x != null</code> to avoid <a href="https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html" rel="noreferrer"><code>NullPointerException</code></a>. Is there an alternative?</p> <pre class="lang-java prettyprint-override"><code>if (x != null) { // ... } </code></pre>
[ { "answer_id": 271553, "author": "Jim Nelson", "author_id": 32168, "author_profile": "https://Stackoverflow.com/users/32168", "pm_score": 6, "selected": false, "text": "<p>Rather than Null Object Pattern -- which has its uses -- you might consider situations where the null object is a bu...
2008/11/07
[ "https://Stackoverflow.com/questions/271526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34856/" ]
I use `x != null` to avoid [`NullPointerException`](https://docs.oracle.com/javase/9/docs/api/java/lang/NullPointerException.html). Is there an alternative? ```java if (x != null) { // ... } ```
This to me sounds like a reasonably common problem that junior to intermediate developers tend to face at some point: they either don't know or don't trust the contracts they are participating in and defensively overcheck for nulls. Additionally, when writing their own code, they tend to rely on returning nulls to indi...
271,530
<p>There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown aw...
[ { "answer_id": 271535, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Yes - the garbage collector can cope with circular references etc.</p>\n" }, { "answer_id": 271556, "auth...
2008/11/07
[ "https://Stackoverflow.com/questions/271530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31993/" ]
There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away....
As stated in this [SO question](https://stackoverflow.com/questions/176745/circular-references-in-java), circular reference is well managed. Java does not do reference counting, it does uses [tracing garbage collection](https://en.wikipedia.org/wiki/Tracing_garbage_collection) (for example mark-and-sweep, copying coll...
271,546
<p>I have an object instance which I access with the ME as it accesses the instantiated object. I have a method that gets a collection of these objects and I wish to assign the first one to the instantiated object. </p> <p>This is some of the code</p> <pre><code>Dim Books As New BookCollection(True) Books.ListByTheme...
[ { "answer_id": 271535, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 2, "selected": false, "text": "<p>Yes - the garbage collector can cope with circular references etc.</p>\n" }, { "answer_id": 271556, "auth...
2008/11/07
[ "https://Stackoverflow.com/questions/271546", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23230/" ]
I have an object instance which I access with the ME as it accesses the instantiated object. I have a method that gets a collection of these objects and I wish to assign the first one to the instantiated object. This is some of the code ``` Dim Books As New BookCollection(True) Books.ListByThemeFeatured(ThemeID, 1) ...
As stated in this [SO question](https://stackoverflow.com/questions/176745/circular-references-in-java), circular reference is well managed. Java does not do reference counting, it does uses [tracing garbage collection](https://en.wikipedia.org/wiki/Tracing_garbage_collection) (for example mark-and-sweep, copying coll...
271,561
<p>In c#, is there any difference in the excecution speed for the order in which you state the condition?</p> <pre><code>if (null != variable) ... if (variable != null) ... </code></pre> <p>Since recently, I saw the first one quite often, and it caught my attention since I was used to the second one.</p> <p>If there...
[ { "answer_id": 271573, "author": "Lasse V. Karlsen", "author_id": 267, "author_profile": "https://Stackoverflow.com/users/267", "pm_score": 3, "selected": false, "text": "<p>I guess this is a C programmer that has switched languages.</p>\n\n<p>In C, you can write the following:</p>\n\n<p...
2008/11/07
[ "https://Stackoverflow.com/questions/271561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26070/" ]
In c#, is there any difference in the excecution speed for the order in which you state the condition? ``` if (null != variable) ... if (variable != null) ... ``` Since recently, I saw the first one quite often, and it caught my attention since I was used to the second one. If there is no difference, what is the ad...
It's a hold-over from C. In C, if you either use a bad compiler or don't have warnings turned up high enough, this will compile with no warning whatsoever (and is indeed legal code): ``` // Probably wrong if (x = 5) ``` when you actually probably meant ``` if (x == 5) ``` You can work around this in C by doing: ...
271,569
<p>I can't seem to set a ContentTemplate for a ComboBoxItem. There reason I'm trying to do this is I want to have 2 appearances for my data in the combo box. When the combo box is open (menu is down) I want a text box (with the name of the image) and an image control below it. When I select the item I want the combo bo...
[ { "answer_id": 271707, "author": "Jobi Joy", "author_id": 8091, "author_profile": "https://Stackoverflow.com/users/8091", "pm_score": 0, "selected": false, "text": "<p>You can achieve this with just ItemsContainerStyle. Add your TextBlock and Image instead of the ContentPresenter. Add th...
2008/11/07
[ "https://Stackoverflow.com/questions/271569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/986/" ]
I can't seem to set a ContentTemplate for a ComboBoxItem. There reason I'm trying to do this is I want to have 2 appearances for my data in the combo box. When the combo box is open (menu is down) I want a text box (with the name of the image) and an image control below it. When I select the item I want the combo box t...
The ComboBox.ItemTemplate is just a convenient way to set the ComboBoxItem.ContentTemplate. So your code above basically tries to set the ComboBoxItem.ContentTemplate twice. As Jobi pointed out, you could try to use just a custom Style. You can safely exclude the ContentPresenter, if you always know the type of the Co...
271,571
<p>Using <a href="http://search.cpan.org/dist/DBIx-Class/" rel="nofollow noreferrer">DBIx::Class</a> and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example:</p> <pre><code>my $resultset = $schem...
[ { "answer_id": 271646, "author": "Aristotle Pagaltzis", "author_id": 9410, "author_profile": "https://Stackoverflow.com/users/9410", "pm_score": 4, "selected": true, "text": "<p>You can’t really, due to the goals for which DBIC result sets are designed:</p>\n\n<ul>\n<li>They compile down...
2008/11/07
[ "https://Stackoverflow.com/questions/271571", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8003/" ]
Using [DBIx::Class](http://search.cpan.org/dist/DBIx-Class/) and I have a resultset which needs to be filtered by data which cannot be generated by SQL. What I need to do is something effectively equivalent to this hypothetical example: ``` my $resultset = $schema->resultset('Service')->search(\%search); my $new_r...
You can’t really, due to the goals for which DBIC result sets are designed: * They compile down to SQL and run a single query, which they do no earlier than when you ask for results. * They are composable. Allowing filtering by code that runs on the Perl side would make it extremely hairy to achieve those properties,...
271,577
<p>i met a problem with iphone simulator application directory, when i run the application everytime, the name of application directory was changed each of time,can anyone tell me how to keep a static application directory ?</p>
[ { "answer_id": 271956, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 0, "selected": false, "text": "<p>If you simply relaunch the app from within the simulator springboard it will keep using the same directory. If yo...
2008/11/07
[ "https://Stackoverflow.com/questions/271577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35405/" ]
i met a problem with iphone simulator application directory, when i run the application everytime, the name of application directory was changed each of time,can anyone tell me how to keep a static application directory ?
i'm going to take a guess here and say.. you don't need a static directory. I think what you need is to get the 'base directory' programatically. ``` NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [docsDirectory stringByA...
271,583
<p>I have a CGI-script which produces a <code>.pdf</code> file from the HTML page. My problem is that when it is launched from the Web Browser, there is no creation of the <code>.pdf</code> document.</p> <p>What I have done so far:</p> <ul> <li>chmod settings set to above recommended (777)</li> <li>tested normal outp...
[ { "answer_id": 271956, "author": "Louis Gerbarg", "author_id": 30506, "author_profile": "https://Stackoverflow.com/users/30506", "pm_score": 0, "selected": false, "text": "<p>If you simply relaunch the app from within the simulator springboard it will keep using the same directory. If yo...
2008/11/07
[ "https://Stackoverflow.com/questions/271583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a CGI-script which produces a `.pdf` file from the HTML page. My problem is that when it is launched from the Web Browser, there is no creation of the `.pdf` document. What I have done so far: * chmod settings set to above recommended (777) * tested normal output on the file from the script, which works fine *...
i'm going to take a guess here and say.. you don't need a static directory. I think what you need is to get the 'base directory' programatically. ``` NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [docsDirectory stringByA...
271,588
<p>Is there a way to pass null arguments to C# methods (something like null arguments in c++)?</p> <p>For example:</p> <p>Is it possible to translate the following c++ function to C# method:</p> <pre><code>private void Example(int* arg1, int* arg2) { if(arg1 == null) { //do something } if(arg...
[ { "answer_id": 271593, "author": "Marcin K", "author_id": 28722, "author_profile": "https://Stackoverflow.com/users/28722", "pm_score": 3, "selected": false, "text": "<p>From C# 2.0:</p>\n\n<pre><code>private void Example(int? arg1, int? arg2)\n{\n if(arg1 == null)\n {\n //d...
2008/11/07
[ "https://Stackoverflow.com/questions/271588", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22996/" ]
Is there a way to pass null arguments to C# methods (something like null arguments in c++)? For example: Is it possible to translate the following c++ function to C# method: ``` private void Example(int* arg1, int* arg2) { if(arg1 == null) { //do something } if(arg2 == null) { //d...
Yes. There are two kinds of types in .NET: reference types and value types. References types (generally classes) are always referred to by references, so they support null without any extra work. This means that if a variable's type is a reference type, the variable is automatically a reference. Value types (e.g. int...
271,595
<p>I need to get all the dates present in the date range using SQL Server 2005</p>
[ { "answer_id": 271607, "author": "Ed Guiness", "author_id": 4200, "author_profile": "https://Stackoverflow.com/users/4200", "pm_score": 3, "selected": false, "text": "<p>If you have the dates in a table and simply want to select those between two dates you can use</p>\n\n<pre><code>selec...
2008/11/07
[ "https://Stackoverflow.com/questions/271595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I need to get all the dates present in the date range using SQL Server 2005
Here you go: ``` DECLARE @DateFrom smalldatetime, @DateTo smalldatetime; SET @DateFrom='20000101'; SET @DateTo='20081231'; ------------------------------- WITH T(date) AS ( SELECT @DateFrom UNION ALL SELECT DateAdd(day,1,T.date) FROM T WHERE T.date < @DateTo ) SELECT date FROM T OPTION (MAXRECURSION 32767); ```
271,598
<p>How do I save a Tlistviews layout in Delphi 2007?</p> <p>I have been asked to write some code to allow users to re-order columns in a TListview (well all TListviews in our application), I have the code working (by manipulating the columns index and setting width to zero to hide columns not needed) but now I need a ...
[ { "answer_id": 271619, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 2, "selected": false, "text": "<p>If you only want to save and load a certain part of the data you can store it n an ini or xml file. \nGeneral data...
2008/11/07
[ "https://Stackoverflow.com/questions/271598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2098/" ]
How do I save a Tlistviews layout in Delphi 2007? I have been asked to write some code to allow users to re-order columns in a TListview (well all TListviews in our application), I have the code working (by manipulating the columns index and setting width to zero to hide columns not needed) but now I need a way to sav...
If you only want to save and load a certain part of the data you can store it n an ini or xml file. General data can be written to the file. Columns is another problem. You need to find an unique identification for each column. The ini could be something like: ``` [Settings] [Col_1] position=1 width=500 title=hello ...
271,609
<p>We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows? </p> <p>Is there any control panel to set the appropriate Java version for different applications, or any other way to set up, what version of Java wi...
[ { "answer_id": 271623, "author": "reallyinsane", "author_id": 35407, "author_profile": "https://Stackoverflow.com/users/35407", "pm_score": 7, "selected": true, "text": "<p>Of course you can use multiple versions of Java under Windows. And different applications can use different Java ve...
2008/11/07
[ "https://Stackoverflow.com/questions/271609", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35061/" ]
We have a couple of applications running on Java 5 and would like now to bring in an application based on Java 6. Can both java versions live together under Windows? Is there any control panel to set the appropriate Java version for different applications, or any other way to set up, what version of Java will be used...
Of course you can use multiple versions of Java under Windows. And different applications can use different Java versions. How is your application started? Usually you will have a batch file where there is something like ``` java ... ``` This will search the Java executable using the PATH variable. So if Java 5 is ...
271,612
<p>I have the following file/line:</p> <pre><code>pc=1 ct=1 av=112 cv=1100 cp=1700 rec=2 p=10001 g=0 a=0 sz=5 cr=200 pc=1 ct=1 av=113 cv=1110 cp=1800 rec=2 p=10001 g=0 a=10 sz=5 cr=200 </code></pre> <p>and so on. I wish to parse this and take the key value pairs and put them in a structure:</p> <pre><code>struct pk...
[ { "answer_id": 271649, "author": "Nik Reiman", "author_id": 14302, "author_profile": "https://Stackoverflow.com/users/14302", "pm_score": 1, "selected": false, "text": "<p>Unfortunately, your source data file is human-oriented, which means that you're going to have to do a bunch of strin...
2008/11/07
[ "https://Stackoverflow.com/questions/271612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
I have the following file/line: ``` pc=1 ct=1 av=112 cv=1100 cp=1700 rec=2 p=10001 g=0 a=0 sz=5 cr=200 pc=1 ct=1 av=113 cv=1110 cp=1800 rec=2 p=10001 g=0 a=10 sz=5 cr=200 ``` and so on. I wish to parse this and take the key value pairs and put them in a structure: ``` struct pky { pky() : a_id(0), ...
You can do something like this: ``` std::string line; std::map<std::string, std::string> props; std::ifstream file("foo.txt"); while(std::getline(file, line)) { std::string token; std::istringstream tokens(line); while(tokens >> token) { std::size_t pos = token.find('='); if(pos != std::str...
271,613
<p>I was reading <em><a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html" rel="nofollow noreferrer">Java Platform Performance</a></em> (sadly the link seems to have disappeared from the internet since I originally posed this question) and section A.3.3 worried me.</p> <p>I had been wor...
[ { "answer_id": 271636, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 1, "selected": false, "text": "<p>Would you really have that much code to analyse? Basically I can only see this being a significant problem for very l...
2008/11/07
[ "https://Stackoverflow.com/questions/271613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7938/" ]
I was reading *[Java Platform Performance](http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html)* (sadly the link seems to have disappeared from the internet since I originally posed this question) and section A.3.3 worried me. I had been working on the assumption that a variable that dropped ou...
This code should clear it up: ``` public class TestInvisibleObject{ public static class PrintWhenFinalized{ private String s; public PrintWhenFinalized(String s){ System.out.println("Constructing from "+s); this.s = s; } protected void finalize() throws Throwable { System.out.printl...
271,615
<p>I have two lists of custom objects and want to update a field for all objects in one list if there is an object in the other list which matches on another pair of fields.</p> <p>This code explains the problem better and produces the results I want. However for larger lists 20k, and a 20k list with matching objects,...
[ { "answer_id": 271645, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 4, "selected": true, "text": "<p>That join should be fairly fast, as it will first loop through all of <code>adjList</code> to create a lookup, then fo...
2008/11/07
[ "https://Stackoverflow.com/questions/271615", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2006748/" ]
I have two lists of custom objects and want to update a field for all objects in one list if there is an object in the other list which matches on another pair of fields. This code explains the problem better and produces the results I want. However for larger lists 20k, and a 20k list with matching objects, this take...
That join should be fairly fast, as it will first loop through all of `adjList` to create a lookup, then for each element in `propList` it will just use the lookup. This is faster than your O(N \* M) method in the larger code - although that could easily be fixed by calling [`ToLookup`](http://msdn.microsoft.com/en-us/...
271,657
<p>I have many emails coming in from different sources. they all have attachments, many of them have attachment names in chinese, so these names are converted to base64 by their email clients.</p> <p>When I receive these emails, I wish to decode the name. but there are other names which are not base64. How can I diffe...
[ { "answer_id": 271693, "author": "gnud", "author_id": 27204, "author_profile": "https://Stackoverflow.com/users/27204", "pm_score": 0, "selected": false, "text": "<p>Well, you parse the email header into a dictionary. And then you check if Content-Transfer-Encoding is set, and if it = \"...
2008/11/07
[ "https://Stackoverflow.com/questions/271657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21537/" ]
I have many emails coming in from different sources. they all have attachments, many of them have attachment names in chinese, so these names are converted to base64 by their email clients. When I receive these emails, I wish to decode the name. but there are other names which are not base64. How can I differentiate w...
> > Please note both `Content-Transfer-Encoding` have base64 > > > Not relevant in this case, the `Content-Transfer-Encoding` only applies to the body payload, not to the headers. ``` =?gb2312?B?uLGxvmhlbrixsb5nLnhscw==?= ``` That's an **RFC2047**-encoded header atom. The stdlib function to decode it is `email....
271,668
<p>Is there a way of converting special folder paths to a full file name (and back) or do I need to code my own (not hard I know, but no point if it exists)</p> <p>e.g. I want to store the file name of a template for an application, which the user can then change, it exists in the LocalApplicationData folder.</p> <p>...
[ { "answer_id": 271683, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 3, "selected": true, "text": "<p>Look at: <a href=\"http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx\" rel=\"nofo...
2008/11/07
[ "https://Stackoverflow.com/questions/271668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6684/" ]
Is there a way of converting special folder paths to a full file name (and back) or do I need to code my own (not hard I know, but no point if it exists) e.g. I want to store the file name of a template for an application, which the user can then change, it exists in the LocalApplicationData folder. what I would like...
Look at: [Environment.ExpandEnvironmentVariables](http://msdn.microsoft.com/en-us/library/system.environment.expandenvironmentvariables.aspx) After some looking around I don't think there is a built-in way available to convert it back, though. You can do this though: ``` static void Main(string[] args) { var val...
271,672
<p>I tried this on J2ME</p> <pre><code>try { Image immutableThumb = Image.createImage( temp, 0, temp.length); } catch (Exception ex) { System.out.println(ex); } </code></pre> <p>I hit this error: <code>java.lang.IllegalArgumentException:</code></p> <p>How do I solve this?</p>
[ { "answer_id": 271680, "author": "Tyler Levine", "author_id": 35339, "author_profile": "https://Stackoverflow.com/users/35339", "pm_score": 1, "selected": false, "text": "<p>Image.createImage() throws an IllegalArgumentException if the first argument is incorrectly formatted or otherwise...
2008/11/07
[ "https://Stackoverflow.com/questions/271672", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I tried this on J2ME ``` try { Image immutableThumb = Image.createImage( temp, 0, temp.length); } catch (Exception ex) { System.out.println(ex); } ``` I hit this error: `java.lang.IllegalArgumentException:` How do I solve this?
Image.createImage() throws an IllegalArgumentException if the first argument is incorrectly formatted or otherwise cannot be decoded. (I'm assuming that temp is a byte[]). <http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Image.html#createImage(byte[],%20int,%20int)> (This URL refuses to beco...
271,675
<p>I have a binded DataGridView where depending on some BoundItem property value that line will be read only. What is the best way to implement this? Thanks</p>
[ { "answer_id": 271679, "author": "CestLaGalere", "author_id": 6684, "author_profile": "https://Stackoverflow.com/users/6684", "pm_score": 0, "selected": false, "text": "<p>in the rowenter event, set the readonly property of the row accordingly</p>\n\n<pre><code>private sub MyView_RowEnte...
2008/11/07
[ "https://Stackoverflow.com/questions/271675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a binded DataGridView where depending on some BoundItem property value that line will be read only. What is the best way to implement this? Thanks
Try The event CellBeginEdit ``` Private Sub Dgv_CellBeginEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellCancelEventArgs) Handles Dgv.CellBeginEdit If YourCondition(BoundItem.Property) then e.cancel = true End Sub ``` This makes the cell readOnly depending on your condition.
271,688
<p><a href="http://dl.getdropbox.com/u/240752/stars.gif" rel="nofollow noreferrer">My screenshot http://dl.getdropbox.com/u/240752/stars.gif</a></p> <p>I want to have it so that only the text is underlined. The only way I can see of doing this is this:</p> <pre><code>.no-underline { text-decoration:none; } .underl...
[ { "answer_id": 271697, "author": "Lasar", "author_id": 9438, "author_profile": "https://Stackoverflow.com/users/9438", "pm_score": 4, "selected": true, "text": "<p>No other solution really. Though you can shorten it a little:</p>\n\n<pre><code>&lt;a href=\"#\" class=\"imgLink\"&gt;&lt;sp...
2008/11/07
[ "https://Stackoverflow.com/questions/271688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26107/" ]
[My screenshot http://dl.getdropbox.com/u/240752/stars.gif](http://dl.getdropbox.com/u/240752/stars.gif) I want to have it so that only the text is underlined. The only way I can see of doing this is this: ``` .no-underline { text-decoration:none; } .underline { text-decoration:underline; } <a href="#" class="n...
No other solution really. Though you can shorten it a little: ``` <a href="#" class="imgLink"><span>Link Text</span> <img src="..."></a> a.imgLink { text-decoration: none; } a.imgLink span { text-decoration: underline; } ``` That way you only need to specify one class.
271,699
<p>Is there any way to (unit) test my own HtmlHelpers? In case when I'd like to have custom control (rendered by HtmlHelper) and I know requierements for that control how could I write tests first - and then write code? Is there a specific (nice) way to do that? </p> <p>Is it worth?</p>
[ { "answer_id": 747186, "author": "Marc Climent", "author_id": 58791, "author_profile": "https://Stackoverflow.com/users/58791", "pm_score": 6, "selected": true, "text": "<p>The main problem is that you have to mock the HtmlHelper because you may be using methods of the helper to get rout...
2008/11/07
[ "https://Stackoverflow.com/questions/271699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3182/" ]
Is there any way to (unit) test my own HtmlHelpers? In case when I'd like to have custom control (rendered by HtmlHelper) and I know requierements for that control how could I write tests first - and then write code? Is there a specific (nice) way to do that? Is it worth?
The main problem is that you have to mock the HtmlHelper because you may be using methods of the helper to get routes or values or returning the result of another extension method. The HtmlHelper class has quite a lot of properties and some of them quite complex like the ViewContext or the current Controller. [This po...
271,706
<p>I basically have a page which shows a "processing" screen which has been flushed to the browser. Later on I need to redirect this page, currently we use meta refresh and this normally works fine. </p> <p>With a new payment system, which includes 3D secure, we potentially end up within an iframe being directed bac...
[ { "answer_id": 271902, "author": "Ben Lynch", "author_id": 15363, "author_profile": "https://Stackoverflow.com/users/15363", "pm_score": 3, "selected": true, "text": "<p>So I added the following to my redirected pages. Luckily they have nothing posted at them so can be simply redirected...
2008/11/07
[ "https://Stackoverflow.com/questions/271706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15363/" ]
I basically have a page which shows a "processing" screen which has been flushed to the browser. Later on I need to redirect this page, currently we use meta refresh and this normally works fine. With a new payment system, which includes 3D secure, we potentially end up within an iframe being directed back to our sit...
So I added the following to my redirected pages. Luckily they have nothing posted at them so can be simply redirected. Also the use of javascript is ok as it is required to get to that point in the site. ``` <script type="text/javascript" language="javascript"> if (top.frames.length>0) setTimeout("top.location...
271,710
<p>The code looks like below:</p> <pre><code>namespace Test { public interface IMyClass { List&lt;IMyClass&gt; GetList(); } public class MyClass : IMyClass { public List&lt;IMyClass&gt; GetList() { return new List&lt;IMyClass&gt;(); } } } </code></pr...
[ { "answer_id": 271711, "author": "Jon Skeet", "author_id": 22656, "author_profile": "https://Stackoverflow.com/users/22656", "pm_score": 6, "selected": false, "text": "<p>I would personally declare it to return an interface rather than a concrete collection. If you really want list acces...
2008/11/07
[ "https://Stackoverflow.com/questions/271710", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11135/" ]
The code looks like below: ``` namespace Test { public interface IMyClass { List<IMyClass> GetList(); } public class MyClass : IMyClass { public List<IMyClass> GetList() { return new List<IMyClass>(); } } } ``` When I Run Code Analysis i get the fo...
To answer the "why" part of the question as to why not [`List<T>`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1), The reasons are future-proofing and API simplicity. **Future-proofing** [`List<T>`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1) is not...
271,718
<p>In a detailsview, how can I prepopulate one of the textboxes on the insertcommand (When the user clicks insert and the view is insert).</p> <p>I think this would work for codebehind:</p> <p>Dim txtBox As TextBox = FormView1.FindControl("txtbox")</p> <p>txtbox.Text = "Whatever I want"</p> <p>Is this right? What d...
[ { "answer_id": 277797, "author": "Alexander Taran", "author_id": 35954, "author_profile": "https://Stackoverflow.com/users/35954", "pm_score": 0, "selected": false, "text": "<p>I'm guessing you need to use one of detailsview events.\nHook up to ItemCommand, ModeChanging or ModeChanged ev...
2008/11/07
[ "https://Stackoverflow.com/questions/271718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32484/" ]
In a detailsview, how can I prepopulate one of the textboxes on the insertcommand (When the user clicks insert and the view is insert). I think this would work for codebehind: Dim txtBox As TextBox = FormView1.FindControl("txtbox") txtbox.Text = "Whatever I want" Is this right? What do I need in the aspx (not as su...
I would update the field in the DetailsView to a TemplateField: ``` <asp:TemplateField> <InsertItemTemplate> <asp:TextBox ID="txtField" runat="server" Text='<%# Bind("GUID") %>'/> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="lblField" runat="server" Text='<%# Bind("GUID") %>'/> </ItemTemplate> <...
271,724
<p>I am playing around with ASP.NET MVC for the first time, so I apologize in advance if this sounds academic. </p> <p>I have created a simple content management system using ASP.NET MVC. The url to retrieve a list of content, in this case, announcements, looks like:</p> <pre><code>http://www.mydomain.com/announcem...
[ { "answer_id": 277797, "author": "Alexander Taran", "author_id": 35954, "author_profile": "https://Stackoverflow.com/users/35954", "pm_score": 0, "selected": false, "text": "<p>I'm guessing you need to use one of detailsview events.\nHook up to ItemCommand, ModeChanging or ModeChanged ev...
2008/11/07
[ "https://Stackoverflow.com/questions/271724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
I am playing around with ASP.NET MVC for the first time, so I apologize in advance if this sounds academic. I have created a simple content management system using ASP.NET MVC. The url to retrieve a list of content, in this case, announcements, looks like: ``` http://www.mydomain.com/announcements/list/10 ``` This...
I would update the field in the DetailsView to a TemplateField: ``` <asp:TemplateField> <InsertItemTemplate> <asp:TextBox ID="txtField" runat="server" Text='<%# Bind("GUID") %>'/> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="lblField" runat="server" Text='<%# Bind("GUID") %>'/> </ItemTemplate> <...
271,730
<p>I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database. </p> <p>I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user. </p> <p>What is the best way of doing it? My preferred solution is a constraint ...
[ { "answer_id": 271768, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 2, "selected": false, "text": "<p>This is difficult because MySQL does not support the LIMIT clause on sub-queries. If it did, this would be rather trivi...
2008/11/07
[ "https://Stackoverflow.com/questions/271730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/103373/" ]
I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database. I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user. What is the best way of doing it? My preferred solution is a constraint that is put on th...
It's pretty easy with a correlated sub-query: ``` SELECT `img`.`id` , `img`.`userid` FROM `img` WHERE 3 > ( SELECT count( * ) FROM `img` AS `img1` WHERE `img`.`userid` = `img1`.`userid` AND `img`.`id` > `img1`.`id` ) ORDER BY `img`.`id` DESC LIMIT 10 ``` The query assumes that larger `id` means added later Correla...
271,741
<p>I'm trying to parse a html page and extract 2 values from a table row. The html for the table row is as follows: -</p> <pre><code>&lt;tr&gt; &lt;td title="Associated temperature in (ºC)" class="TABLEDATACELL" nowrap="nowrap" align="Left" colspan="1" rowspan="1"&gt;Max Temperature (ºC)&lt;/td&gt; &lt;td class="TABLE...
[ { "answer_id": 271748, "author": "siukurnin", "author_id": 35273, "author_profile": "https://Stackoverflow.com/users/35273", "pm_score": 0, "selected": false, "text": "<p>When you write <code>&lt;td[^&lt;]+?&gt;</code> I guess you really mean <code>&lt;td[^&gt;]*&gt;</code></p>\n\n<p>Tha...
2008/11/07
[ "https://Stackoverflow.com/questions/271741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to parse a html page and extract 2 values from a table row. The html for the table row is as follows: - ``` <tr> <td title="Associated temperature in (ºC)" class="TABLEDATACELL" nowrap="nowrap" align="Left" colspan="1" rowspan="1">Max Temperature (ºC)</td> <td class="TABLEDATACELLNOTT" nowrap="nowrap" align...
Try ``` <tr>\s* <td[^>]*>.*?</td>\s* <td[^>]*>\s*(?<value>\d+)\s*</td>\s* <td[^>]*>\s*(?<time>\d{2}:\d{2}:\d{2})\s*</td>\s* </tr>\s* ```
271,742
<p>What are the advantages of rendering a control like this:</p> <pre><code>&lt;% Html.RenderPartial("MyControl") %&gt; or &lt;%=Html.TextBox("txtName", Model.Name) %&gt; </code></pre> <p>over the web Forms style:</p> <pre><code>&lt;uc1:MyControl ID=MyControl runat=server /&gt; </code></pre> <p>I understand that pe...
[ { "answer_id": 271780, "author": "TheCodeJunkie", "author_id": 25319, "author_profile": "https://Stackoverflow.com/users/25319", "pm_score": 3, "selected": false, "text": "<p>There are a couple of reasons for this. A \"traditional\" ASP.NET WebForm control encapsulates both the Controlle...
2008/11/07
[ "https://Stackoverflow.com/questions/271742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4264/" ]
What are the advantages of rendering a control like this: ``` <% Html.RenderPartial("MyControl") %> or <%=Html.TextBox("txtName", Model.Name) %> ``` over the web Forms style: ``` <uc1:MyControl ID=MyControl runat=server /> ``` I understand that performance can be one reason because no object needs to be created b...
Doing null checks in the view is probably going to cause grief in the long run. The way I interpret the MVC style of programming is to prepare the view data in the controller so that the view can be really clean and not sprincled with checks and conditions. On the other hand, if there is the need follow potentially nu...
271,767
<p>I have in my Form constructor, after the InitializeComponent the following code:</p> <pre><code>using (WebClient client = new WebClient()) { client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted); client.DownloadDataAsync("http://example.com/version.txt"); } </co...
[ { "answer_id": 271774, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 1, "selected": false, "text": "<p>You want to run the download in a different thread, see <a href=\"http://msdn.microsoft.com/en-us/library/system...
2008/11/07
[ "https://Stackoverflow.com/questions/271767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4386/" ]
I have in my Form constructor, after the InitializeComponent the following code: ``` using (WebClient client = new WebClient()) { client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted); client.DownloadDataAsync("http://example.com/version.txt"); } ``` When I start...
Now that we've got full code, I can say I'm definitely not seeing the problem - not quite as described, anyway. I've got a bit of logging to indicate just before and after the DownloadDataAsync calls, and when the completed handler is fired. If I download a large file over 3G, there *is* a pause between "before" and "...
271,806
<p>This is a simplification of the issue (there are lots of ways of doing things), but among applications that need to talk to a database I have usually seen one of two patterns:</p> <ol> <li>Object-Relational Mapping (ORM), where (usually) each table in the database has a corresponding "row wrapper" class with public...
[ { "answer_id": 271819, "author": "Andrew Bullock", "author_id": 28543, "author_profile": "https://Stackoverflow.com/users/28543", "pm_score": 0, "selected": false, "text": "<p>I used to just use a datareader to read fields onto my object using GetString, GetInt etc. but i've moved on now...
2008/11/07
[ "https://Stackoverflow.com/questions/271806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14606/" ]
This is a simplification of the issue (there are lots of ways of doing things), but among applications that need to talk to a database I have usually seen one of two patterns: 1. Object-Relational Mapping (ORM), where (usually) each table in the database has a corresponding "row wrapper" class with public properties t...
Datatable will certainly be conceptually more straight forward in working with data. And its devoid of sometimes unnatural idioms that you find in ORM. (querying a record into local memory, before updating it; joins are pointers; the key value itself is a pointer, hence, adding a record requires loading the parent reco...
271,815
<p>Is there a better way to write this code? </p> <p>I want to show a default value ('No data') for any empty fields returned by the query:</p> <pre><code>$archivalie_id = $_GET['archivalie_id']; $query = "SELECT a.*, ip.description AS internal_project, o.descript...
[ { "answer_id": 271826, "author": "Stefan Gehrig", "author_id": 11354, "author_profile": "https://Stackoverflow.com/users/11354", "pm_score": 3, "selected": true, "text": "<p>You could use a small helper function</p>\n\n<pre><code>function dbValue($value, $default=null)\n{\n if ($defau...
2008/11/07
[ "https://Stackoverflow.com/questions/271815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4196/" ]
Is there a better way to write this code? I want to show a default value ('No data') for any empty fields returned by the query: ``` $archivalie_id = $_GET['archivalie_id']; $query = "SELECT a.*, ip.description AS internal_project, o.description AS origin, ...
You could use a small helper function ``` function dbValue($value, $default=null) { if ($default===null) { $default='<span class="no-data">No data</span>'; } if (!empty($value)) { return $value; } else { return $default; } } ```
271,821
<p>I have a site that usually has news items at the top of the homepage, and sometimes (for specific periods) will have one or more 'quicklinks' beneath the news items, to guide users to pages of topical interest. Beneath those is the usual blurb.</p> <p>We have alternative language versions of these sites, which ofte...
[ { "answer_id": 271827, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 3, "selected": true, "text": "<pre><code>.top100 {top: 100px;}\n.top150 {top: 150px;}\n.top200 {top: 200px;}\n.top250 {top: 250px;}\n</code></pre>\n...
2008/11/07
[ "https://Stackoverflow.com/questions/271821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6898/" ]
I have a site that usually has news items at the top of the homepage, and sometimes (for specific periods) will have one or more 'quicklinks' beneath the news items, to guide users to pages of topical interest. Beneath those is the usual blurb. We have alternative language versions of these sites, which often don't co...
``` .top100 {top: 100px;} .top150 {top: 150px;} .top200 {top: 200px;} .top250 {top: 250px;} ``` Is a bad practice, because you now add style information into the HTML. Better use descriptive names and link them together. Like: ``` .news {top: 100px; etc...;} .news2, .ql {top: 150px; etc...;} .ql2, .main {top: 200px;...
271,850
<p>After upgrading a project from Delphi 2007 to Delphi 2009 I'm getting an Unknown memory leak, so far I've been tryin to track it down using fastMM, here is what fastMM stack trace reports:</p> <pre><code>A memory block has been leaked. The size is: 20 This block was allocated by thread 0x111C, and the stack trace ...
[ { "answer_id": 271977, "author": "utku_karatas", "author_id": 14716, "author_profile": "https://Stackoverflow.com/users/14716", "pm_score": 0, "selected": false, "text": "<p>IIRC VCL had a few very small leaks like this that you can ignore without much worry. This might be one of them!? ...
2008/11/07
[ "https://Stackoverflow.com/questions/271850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/727/" ]
After upgrading a project from Delphi 2007 to Delphi 2009 I'm getting an Unknown memory leak, so far I've been tryin to track it down using fastMM, here is what fastMM stack trace reports: ``` A memory block has been leaked. The size is: 20 This block was allocated by thread 0x111C, and the stack trace (return addres...
This memory leak was being caused by a Delphi bug, QC [#67709](http://qc.embarcadero.com/wc/qcmain.aspx?d=67709) It was fixed by the last Delphi 2009 update, no wonder I wasn't able to fix it.
271,888
<p>In my database application I sometimes have to deal with <code>null</code> strings in the database. In most cases this is fine, but when it comes do displaying data in a form the Swing components - using <code>JTextField</code> for example - cannot handle null strings. (<code>.setText(null)</code> fails)</p> <p>(<s...
[ { "answer_id": 271894, "author": "Tomo", "author_id": 9622, "author_profile": "https://Stackoverflow.com/users/9622", "pm_score": 0, "selected": false, "text": "<p>If you can, add a default value - empty string - for a field in DB .</p>\n" }, { "answer_id": 271897, "author": ...
2008/11/07
[ "https://Stackoverflow.com/questions/271888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23368/" ]
In my database application I sometimes have to deal with `null` strings in the database. In most cases this is fine, but when it comes do displaying data in a form the Swing components - using `JTextField` for example - cannot handle null strings. (`.setText(null)` fails) (**EDIT:** I just noticed that `JTextField` ac...
If you are using any ORM tool or somehow you map your DB fields to Java bean you can allways have: ``` public void setFoo(String str) { this.foo = str != null ? str : ""; } ```
271,892
<p>I have a &lt;select&gt;. Using JavaScript, I need to get a specific &lt;option&gt; from the list of options, and all I know is the value of the option. The option may or may not be selected.</p> <p>Here's the catch: there are thousands of options and I need to do this a few hundred times in a loop. Right now I loo...
[ { "answer_id": 271903, "author": "Davide Gualano", "author_id": 28582, "author_profile": "https://Stackoverflow.com/users/28582", "pm_score": -1, "selected": false, "text": "<p>With jQuery something like this could be faster:</p>\n\n<pre><code>$(\"#idselect option[value='yourval']\")\n</...
2008/11/07
[ "https://Stackoverflow.com/questions/271892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4641/" ]
I have a <select>. Using JavaScript, I need to get a specific <option> from the list of options, and all I know is the value of the option. The option may or may not be selected. Here's the catch: there are thousands of options and I need to do this a few hundred times in a loop. Right now I loop through the "options"...
I'd do it like this: ``` // first, build a reverse lookup var optCount = mySelect.options.length; var reverseLookup = {}; for (var i = 0; i < optCount; i++) { var option = mySelect.options[i]; if (!reverseLookup[option.value]) { // use an array to account for multiple options with the same value rev...
271,904
<p>Say you have a class declaration, e.g.:</p> <pre><code> class MyClass { int myInt=7; int myOtherInt; } </code></pre> <p>Now, is there a way in generic code, using reflection (or any other means, for that matter), that I can deduce that myInt has a default value assigned, whereas myOtherInt does not? Note the d...
[ { "answer_id": 271919, "author": "John Lemp", "author_id": 12915, "author_profile": "https://Stackoverflow.com/users/12915", "pm_score": 2, "selected": false, "text": "<p>You might want to consider a nullable int for this behavior:</p>\n\n<pre><code>class MyClass\n{\n int? myInt = 7;\n ...
2008/11/07
[ "https://Stackoverflow.com/questions/271904", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32136/" ]
Say you have a class declaration, e.g.: ``` class MyClass { int myInt=7; int myOtherInt; } ``` Now, is there a way in generic code, using reflection (or any other means, for that matter), that I can deduce that myInt has a default value assigned, whereas myOtherInt does not? Note the difference between being in...
I compiled your code and load it up in ILDASM and got this ``` .method public hidebysig specialname rtspecialname instance void .ctor() cil managed { // Code size 15 (0xf) .maxstack 8 IL_0000: ldarg.0 IL_0001: ldc.i4.7 IL_0002: stfld int32 dummyCSharp.MyClass::myInt IL_...