Posts

generics - List.AddRange Has Some Invalid Arguments -

i want create list of flowers (for example) conform predefined iflower interface below. public interface iflower { string colour { get; } int petals { get; } } public class rose : iflower { public rose() { string[] colours = new string[]{ "pink", "orange", "red", "crimson", "cerise" }; random random = new random(); colour = colours[random.next(0, 4)]; } public string colour { get; set; } public int petals { { return 8; } } } public class daisy : iflower{ public daisy() { string[] colours = new string[]{ "white", "yellow", "purple" }; random random = new random(); colour = colours[random.next(0, 2)]; } public string colour { get; set; } public int petals { { return 18; } } } public class flowers { public list<daisy> daisies { { ...

c++ - Optimal virtual machine/byte-code interpreter loop -

my project has vm executes byte-code compiled domain-specific-language. i'm looking @ ways can improve execution time of byte-code. first step i'd see if there way improve byte-code interpreter before venture machine code compilation. the main loop of interpreter looks this: while(true) { uint8_t cmd = *code++; switch( cmd ) { case op_1: ...; break; ... } } question: there faster way implement loop without resorting assembler? the 1 option see gcc specific use dynamic goto label addresses. rather break @ end of each case jump directly next instruction. had hoped optimizer me, looking @ disassembly apparently doesn't: there repeated constant jump @ end of op_codes. if relevant vm simple register based machine floating point , integer registers (8 of each). there no stack, global heap (that language not complicated). one easy optimisation instead of switch /case/case/case/case/case, just define array function pointers (where each f...

c# - Serialize a derived type without the type and namespace attributes -

i have xml api have mimic character character. i'm trying use built-in xml serialization functionality in .net, it's adding attributes. in normal web service or xml api, these attributes wouldn't hurt , might serve purpose. unexpected characters and, unfortunately, cannot allow them. here's i'd (with hypothetical objects of course): i have base type public abstract class instrument { } ...and have derived type public class guitar : instrument { } ...and serialize derived type this: <guitar /> instead, this: <instrument d1p1:type="guitar" xmlns:d1p1="http://www.w3.org/2001/xmlschema-instance" /> here's test i'm working with: [testclass] public class when_serializing_a_guitar { private xmlserializer _serializer; private string _expectedxml; private stringwriter _stringwriter; private string _actualxml; private xmlserializernamespaces _ns; private xmlwriter _xmlwriter; private ...

Flex TitleWindow (or NativeWindow) skinned as a Fancybox? -

the customer working wants display popup in air application (designed in flex 4).i therefore use titlewindow , popupmanager (or nativewindow option too). pretty basic, can handle this. trouble is, customer popup looking fancybox , is, close button, out of popup. do know how ? easy enough. create custom skin based titlewindow can change appearance , location of close button (among other things). setup straightforward, should how skin in flex 4 .

java - Why does System.getProperty("line.seperator") return null? -

exactly title asks, why system.getproperty("line.seperator") returning null. from looking around gather shouldn't. running code shows seems set line separator broken: class test { public static void main( string[] args ) { system.out.println(system.getproperties()); } } $ java test {java.runtime.name=java(tm) se runtime environment, sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386, java.vm.version=19.1-b02, java.vm.vendor=sun microsystems inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=java hotspot(tm) server vm, file.encoding.pkg=sun.io, sun.java.launcher=sun_standard, user.country=gb, sun.os.patch.level=unknown, java.vm.specification.name=java virtual machine specification, user.dir=/home/niko, java.runtime.version=1.6.0_24-b07, java.awt.graphicsenv=sun.awt.x11graphicsenvironment, java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.sepa...

objective c - looping in iphone -

possible duplicate: for loop , if statement hi everyone, have following loop , preeceding if else condition.m using following code. for (int intprjname=0 ; intprjname<[arrprjname count] ;intprjname++) { if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname]) { //some code } else { //some code } } suppose strselectedprojectname "aaa"and arrprjname contains "aaa" "bbb" "ccc" .. after first iteration of loop if condition gets true i.e string "aaa" matches string in array list,it should out of loop @ second iteration,i.e should not enter else condition.. add break; command for (int intprjname=0 ; intprjname<[arrprjname count] ;intprjname++) { if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname]) { //some code break; } else { //some code } } ...

How to pass NULL value for integer/fixnum type in ruby for SOAP request -

i need invoke method getquotedata() through soap request using parameters: username , password , id , revnum revnum revision number of data fetching. can have values ... 1,2,3... , on. if pass null value it, latest data. how can initialize integer null value in ruby method call? method call not work if pass nil revnum or if not send parameter. below our sample method call: getquotedata(:username => user, :password=> pass, id => "xks32", revnum=> 0) the wsdl definition of method is: <s:element name="getquotedata"> <s:complextype> <s:sequence> <s:element minoccurs="0" maxoccurs="1" name="username" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="password" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="cartcompositenumber" type="s:str...