Search Results

Search found 504 results on 21 pages for 'charles lamb'.

Page 12/21 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Create a new delegate class for each asynchronous image download?

    - by Charles S.
    First, I'm using an NSURLConnection to download JSON data from twitter. Then, I'm using a second NSURLConnection to download corresponding user avatar images (the urls to the images are parsed from the first data download). For the first data connection, I have my TwitterViewController set as the NSURLConnection delegate. I've created a separate class (ImageDownloadDelegate) to function as the delegate for a second NSURLConnection that handles the images. After the tweets are finished downloading, I'm using this code to get the avatars: for(int j=0; j<[self.tweets count]; j++){ ImageDownloadDelegate *imgDelegate = [[ImageDownloadDelegate alloc] init]; Tweet *myTweet = [self.tweets objectAtIndex:j]; imgDelegate.tweet = myTweet; imgDelegate.table = timeline; NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:myTweet.imageURL] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60]; imgConnection = [[NSURLConnection alloc] initWithRequest:request delegate:imgDelegate]; [imgDelegate release]; } So basically a new instance of the delegate class is created for each image that needs to be downloaded. Is this the best way to go about this? But then there's no way to figure out which image is associate with which tweet, correct? The algorithm works fine... I'm just wondering if I'm going about it the most efficient way.

    Read the article

  • Use WM_COPYDATA to send data between processes

    - by Charles Gargent
    I wish to send text between processes. I have found lots of examples of this but none that I can get working. Here is what I have so far: for the sending part: COPYDATASTRUCT CDS; CDS.dwData = 1; CDS.cbData = 8; CDS.lpData = NULL; SendMessage(hwnd, WM_COPYDATA , (WPARAM)hwnd, (LPARAM) (LPVOID) &CDS); the receiving part: case WM_COPYDATA: COPYDATASTRUCT* cds = (COPYDATASTRUCT*) lParam; I dont know how to construct the COPYDATASTRUCT, I have just put something in that seems to work. When debugging the WM_COPYDATA case is executed, but again I dont know what to do with the COPYDATASTRUCT. I would like to send text between the two processes. As you can probably tell I am just starting out, I am using GNU GCC Compiler in Code::Blocks, I am trying to avoid MFC and dependencies.

    Read the article

  • onclick event not working after ie7 reload

    - by Charles
    I am using Javascript to dynamically create part of my page content. A routine that generates a set of img tags is called from the window.onload event. Those img tags are assigned attributes, including an onclick event. The img tags host thumbnail images that, when clicked, change the src property of the image in the main view div. Everything works properly in FF 3.5. I can reload the page and the dynamically generated onclick events continue to fire as expected. In IE7 everything works normally until I reload the page. At that point events that were hard coded into the xhtml section continue to work as expected, and the dynamically generated img tags are shown on the page, but their onclick events fail to work. How can I get IE7 to implement the dynamically generated click events on reload?

    Read the article

  • Create a bubble effect on a grid OpenGL-ES

    - by Charles Michael
    Hi there. I have created a grid with 40 x 40 vertex3D (small but useful) I can pick a single vertex out of that grid by simply calling a function with the position array[X][Y], And therefore neighbors too. How can I raise up neighbor vertex Z value so they kinda look like a bubble or sphere kind of thingy? My first tough was to use: Neighbor_vertex.Z = sin(PI/4 * 1 - ( 1/ distance_between_Neighbor_and_Pivot) ) * desired_Max_Height But all I got is something like a wave.... and I would like to have a bubble or Sphere like shape. THX dudes and dudettes

    Read the article

  • datatable works in C# winform but not ASP.NET

    - by Charles Gargent
    Hi I have created a class that returns a datatable, when I use the class in a c# winform the dataGridView is populted corectly using the following code dataGridView1.DataSource = dbLib.GetData(); However when I try the same thing with ASP.NET I get a Object reference not set to an instance of an object. using the following code GridView1.DataSource = dbLib.GetData(); GridView1.DataBind(); What am I doing wrong / missing Thanks EDIT for the curios here is the dbLib class public static DataTable GetData() { SQLiteConnection cnn = new SQLiteConnection("Data Source=c:\\test.db"); SQLiteCommand cmd = new SQLiteCommand("SELECT count(Message) AS Occurances, Message FROM evtlog GROUP BY Message ORDER BY Occurances DESC LIMIT 25", cnn); cnn.Open(); SQLiteDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); DataTable dt = new DataTable(); dt.Load(dr); return dt; }

    Read the article

  • How to select the nth row in a SQL database table?

    - by Charles Roper
    I'm interested in learning some (ideally) database agnostic ways of selecting the nth row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: SQL Server MySQL PostgreSQL SQLite Oracle I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches: WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000 Credit for the above SQL: Firoz Ansari's Weblog Update: See Troels Arvin's answer regarding the SQL standard. Troels, have you got any links we can cite?

    Read the article

  • Can resources be extracted from a compiled iPhone app? If yes, how can they be secured?

    - by Charles S.
    Can resources be extracted from a compiled iPhone app that is released to the iTunes store? I'm particularly interested in the security of XML files... if I have copyrighted data in an XML document in my resource directory, how likely is it for someone to extract that information and paste it around the internet? If it's as easy as using a resource editor, how can that data be secured?

    Read the article

  • Browsers disagree about the text of a body element

    - by Charles Anderson
    My HTML looks like this: <html> <head> <title>Test</title> <script type="text/javascript" src="jQuery.js"></script> <script type="text/javascript"> function init() { var text = jQuery('body').text(); alert('length = ' + text.length); } </script> </head> <body onload="init()">0123456789</body> </html> When I load this in Firefox, the length is reported as 10. However, in Chrome it's 11 because it thinks there's a linefeed after the '9'. In IE it's also 11, but the last character is an escape. Meanwhile, Opera thinks there are 12 characters, with the last two being CR LF. If I change the body element to include a span: <body onload="init()"><span>0123456789</span></body> and the jQuery call to: var text = jQuery('body span').text(); then all the browsers agree that the length is 10. Clearly it's the body element that's causing the issue, but can anyone explain exactly why this is happening? I'm particularly surprised because the excellent jQuery is normally browser-independent.

    Read the article

  • Can't switch on designMode in Internet Explorer

    - by Charles Anderson
    The following code works in Firefox 3.6, but not in Internet Explorer 8: <html> <head> <title>Example</title> <script type="text/javascript"> function init() { alert(document.designMode); document.designMode = "on"; alert(document.designMode); } </script> </head> <body onload="init()"> </body> </html> In FF the alerts show 'off', then 'on'; in IE they're both 'Off'. What am I doing wrong?

    Read the article

  • problem with select boxes - second options based on first selection

    - by Charles Marsh
    Hello All, I just posted a question about opening in a new window but if I use window.location it doesn't work?? is there a problem with my javascript? <script type="text/javascript"> function setOptions(chosen){ var selbox = document.formName.table; selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('No diploma selected',' '); } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('first choice - option one','http://www.pitman-training.com'); selbox.options[selbox.options.length] = new Option('first choice - option two','onetwo'); } if (chosen == "2") { selbox.options[selbox.options.length] = new Option('second choice - option one','twoone'); selbox.options[selbox.options.length] = new Option('second choice - option two','twotwo'); selbox.options[selbox.options.length] = new Option('second choice - option three','twothree'); selbox.options[selbox.options.length] = new Option('second choice - option four','twofour'); } if (chosen == "3") { selbox.options[selbox.options.length] = new Option('third choice - option one','threeone'); selbox.options[selbox.options.length] = new Option('third choice - option two','threetwo'); } } </script> Its a little messy I know... <form name="formName" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <select name="optone" size="1" onchange="setOptions(document.formName.optone.options[document.formName.optone.selectedIndex].value);"> <option value=" " selected="selected">Please select a diploma</option> <option value="1">First Choice</option> <option value="2">Second Choice</option> <option value="3">Third Choice</option> </select> <select name="table" size="1" > <option value=" " selected="selected">No diploma selected</option> </select> <input type="submit" onclick="ob=this.form.table;window.location(ob.options[ob.selectedIndex].value)"/> </form> to be honest I'm not happy with this anyway I want a way to hide the Submit button until the second selected box has been selected...but I'm no java expert! Can anyone point me in the right direction?

    Read the article

  • Python urllib.urlopen() call doesn't work with a URL that a browser accepts

    - by Charles Anderson
    If I point Firefox at http://bitbucket.org/tortoisehg/stable/wiki/Home/ReleaseNotes, I get a page of HTML. But if I try this in Python: import urllib site = 'http://bitbucket.org/tortoisehg/stable/wiki/Home/ReleaseNotes' req = urllib.urlopen(site) text = req.read() I get the following: 500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. What am I doing wrong?

    Read the article

  • Cascading S3 Sink Tap not being deleted with SinkMode.REPLACE

    - by Eric Charles
    We are running Cascading with a Sink Tap being configured to store in Amazon S3 and were facing some FileAlreadyExistsException (see [1]). This was only from time to time (1 time on around 100) and was not reproducable. Digging into the Cascading codem, we discovered the Hfs.deleteResource() is called (among others) by the BaseFlow.deleteSinksIfNotUpdate(). Btw, we were quite intrigued with the silent NPE (with comment "hack to get around npe thrown when fs reaches root directory"). From there, we extended the Hfs tap with our own Tap to add more action in the deleteResource() method (see [2]) with a retry mechanism calling directly the getFileSystem(conf).delete. The retry mechanism seemed to bring improvement, but we are still sometimes facing failures (see example in [3]): it sounds like HDFS returns isDeleted=true, but asking directly after if the folder exists, we receive exists=true, which should not happen. Logs also shows randomly isDeleted true or false when the flow succeeds, which sounds like the returned value is irrelevant or not to be trusted. Can anybody bring his own S3 experience with such a behavior: "folder should be deleted, but it is not"? We suspect a S3 issue, but could it also be in Cascading or HDFS? We run on Hadoop Cloudera-cdh3u5 and Cascading 2.0.1-wip-dev. [1] org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory s3n://... already exists at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:132) at com.twitter.elephantbird.mapred.output.DeprecatedOutputFormatWrapper.checkOutputSpecs(DeprecatedOutputFormatWrapper.java:75) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:923) at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:882) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:396) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1278) at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:882) at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:856) at cascading.flow.hadoop.planner.HadoopFlowStepJob.internalNonBlockingStart(HadoopFlowStepJob.java:104) at cascading.flow.planner.FlowStepJob.blockOnJob(FlowStepJob.java:174) at cascading.flow.planner.FlowStepJob.start(FlowStepJob.java:137) at cascading.flow.planner.FlowStepJob.call(FlowStepJob.java:122) at cascading.flow.planner.FlowStepJob.call(FlowStepJob.java:42) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.j [2] @Override public boolean deleteResource(JobConf conf) throws IOException { LOGGER.info("Deleting resource {}", getIdentifier()); boolean isDeleted = super.deleteResource(conf); LOGGER.info("Hfs Sink Tap isDeleted is {} for {}", isDeleted, getIdentifier()); Path path = new Path(getIdentifier()); int retryCount = 0; int cumulativeSleepTime = 0; int sleepTime = 1000; while (getFileSystem(conf).exists(path)) { LOGGER .info( "Resource {} still exists, it should not... - I will continue to wait patiently...", getIdentifier()); try { LOGGER.info("Now I will sleep " + sleepTime / 1000 + " seconds while trying to delete {} - attempt: {}", getIdentifier(), retryCount + 1); Thread.sleep(sleepTime); cumulativeSleepTime += sleepTime; sleepTime *= 2; } catch (InterruptedException e) { e.printStackTrace(); LOGGER .error( "Interrupted while sleeping trying to delete {} with message {}...", getIdentifier(), e.getMessage()); throw new RuntimeException(e); } if (retryCount == 0) { getFileSystem(conf).delete(getPath(), true); } retryCount++; if (cumulativeSleepTime > MAXIMUM_TIME_TO_WAIT_TO_DELETE_MS) { break; } } if (getFileSystem(conf).exists(path)) { LOGGER .error( "We didn't succeed to delete the resource {}. Throwing now a runtime exception.", getIdentifier()); throw new RuntimeException( "Although we waited to delete the resource for " + getIdentifier() + ' ' + retryCount + " iterations, it still exists - This must be an issue in the underlying storage system."); } return isDeleted; } [3] INFO [pool-2-thread-15] (BaseFlow.java:1287) - [...] at least one sink is marked for delete INFO [pool-2-thread-15] (BaseFlow.java:1287) - [...] sink oldest modified date: Wed Dec 31 23:59:59 UTC 1969 INFO [pool-2-thread-15] (HiveSinkTap.java:148) - Now I will sleep 1 seconds while trying to delete s3n://... - attempt: 1 INFO [pool-2-thread-15] (HiveSinkTap.java:130) - Deleting resource s3n://... INFO [pool-2-thread-15] (HiveSinkTap.java:133) - Hfs Sink Tap isDeleted is true for s3n://... ERROR [pool-2-thread-15] (HiveSinkTap.java:175) - We didn't succeed to delete the resource s3n://... Throwing now a runtime exception. WARN [pool-2-thread-15] (Cascade.java:706) - [...] flow failed: ... java.lang.RuntimeException: Although we waited to delete the resource for s3n://... 0 iterations, it still exists - This must be an issue in the underlying storage system. at com.qubit.hive.tap.HiveSinkTap.deleteResource(HiveSinkTap.java:179) at com.qubit.hive.tap.HiveSinkTap.deleteResource(HiveSinkTap.java:40) at cascading.flow.BaseFlow.deleteSinksIfNotUpdate(BaseFlow.java:971) at cascading.flow.BaseFlow.prepare(BaseFlow.java:733) at cascading.cascade.Cascade$CascadeJob.call(Cascade.java:761) at cascading.cascade.Cascade$CascadeJob.call(Cascade.java:710) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619)

    Read the article

  • Adapter for circle page indicator in android

    - by Charles LAU
    I am currently working on an android application which have multiple pages. I am trying to use Circle page indicator to allow users view multiple pages by flipping over the screen. Each page has seperate XML file for the view and each page has a button which is bind to a java method in the Activity. I would like to know how to initalise all the buttons in the Activity for multiple pages. Because at the moment, I can only initalise the button for the first page of the views. I cannot initalise the button for second and third page. Does anyone know how to achieve this. I have placed all the jobs to be done for all the buttons in a single activity. I am currently using this indicator : http://viewpagerindicator.com/ Here is my adapter for the circle page indicator: @Override public Object instantiateItem(View collection, int position) { inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); int resid = 0; //View v = null;// inflater.inflate( R.layout.gaugescreen, (ViewPager)collection, false ); switch( position ) { case 0: resid = R.layout.gaugescreen; break; case 1: resid= R.layout.liveworkoutstatisticsscreen; break; case 2: resid = R.layout.mapscreen; break; default: resid = R.layout.gaugescreen; break; } View view = inflater.inflate(resid, null); ((ViewPager) collection).addView(view,0); return view; } Does anyone know how to achieve this? Thanks for any help in advance

    Read the article

  • How do I find and open a file in a Visual Studio 2005 add-in?

    - by Charles Randall
    I'm making an add-in with Visual Studio 2005 C# to help easily toggle between source and header files, as well as script files that all follow a similar naming structure. However, the directory structure has all of the files in different places, even though they are all in the same project. I've got almost all the pieces in place, but I can't figure out how to find and open a file in the solution based only on the file name alone. So I know I'm coming from, say, c:\code\project\subproject\src\blah.cpp, and I want to open c:\code\project\subproject\inc\blah.h, but I don't necessarily know where blah.h is. I could hardcode different directory paths but then the utility isn't generic enough to be robust. The solution has multiple projects, which seems to be a bit of a pain as well. I'm thinking at this point that I'll have to iterate through every project, and iterate through every project item, to see if the particular file is there, and then get a proper reference to it. But it seems to me there must be an easier way of doing this.

    Read the article

  • What does og:image meta data do with the Facebook Like iframe?

    - by Charles Boyung
    I am working on putting the Facebook "Like" iframe on a site, and I am trying to follow the example found at http://developers.facebook.com/docs/reference/plugins/like. I am putting in code similar to this: <meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/> But when I "Like" a page, it doesn't do anything with the image that I am aware of. Does anyone know what that data is supposed to do?

    Read the article

  • htaccess for swf file

    - by Charles Wayne
    Does htaccess works with swf file that accepts variables? I have this swf url... http://subdom.domain.tld/subfolder/live.swf?stream=rtmp://stream.domain.com/application&provider=rtmp&file=streamname&autostart=true I want it to be rewrite as http://subdom.domain.tld/subfolder/assignedname/ So far this is what I written on .htaccess file RewriteEngine On RewriteRule ^kwt/?$ live.swf?stream=rtmp://stream.domain.com/application&provider=rtmp&file=streamname&autostart=true [NC,L] It does seem to rewrite to the swf file because the swf is showing but for some reason the variable is not recognized. It does not auto play even the auto play variable is set to true in the RewriteRule. Is there something wrong with my code or it can't be done in swf file?

    Read the article

  • clojure: ExceptionInInitializerError in Namespace.<init> loading from a non-default classpath

    - by Charles Duffy
    In attempting to load an AOT-compiled class from a non-default classpath, I receive the following exception: Traceback (innermost last): File "test.jy", line 10, in ? at clojure.lang.Namespace.<init>(Namespace.java:34) at clojure.lang.Namespace.findOrCreate(Namespace.java:176) at clojure.lang.Var.internPrivate(Var.java:149) at aot_demo.JavaClass.<clinit>(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError I'm able to reproduce this with the following trivial project.clj: (defproject aot-demo "0.1.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.3.0"]] :aot [aot-demo.core]) ...and src/aot_demo/core.clj defined as follows: (ns aot-demo.core (:gen-class :name aot_demo.JavaClass :methods [#^{:static true} [lower [java.lang.String] java.lang.String]])) (defn -lower [str] (.toLower str)) The following Jython script is then sufficient to trigger the bug: #!/usr/bin/jython import java.lang.Class import java.net.URLClassLoader import java.net.URL import os cl = java.net.URLClassLoader( [java.net.URL('file://%s/target/aot-demo-0.1.0-SNAPSHOT-standalone.jar' % (os.getcwd()))]) java.lang.Class.forName('aot_demo.JavaClass', True, cl) However, the exception does not occur if the test script is started with the uberjar already in the CLASSPATH variable. What's going on here? I'm trying to write a plugin for the BaseX database in Clojure; the above accurately represents how their plugin-loading mechanism works for the purpose of providing a SSCE for this problem.

    Read the article

  • Accessing CSR extension stack in M2Crypto

    - by Charles Duffy
    Howdy! I have a certificate signing request with an extension stack added. When building a certificate based on this request, I would like to be able to access that stack to use in creating the final certificate. However, while M2Crypto.X509.X509 has a number of helpers for accessing extensions (get_ext, get_ext_at and the like), M2Crypto.X509.Request appears to provide only a member for adding extensions, but no way to inspect the extensions already associated with a given object. Am I missing something here?

    Read the article

  • Post Method Not giving Alerts like planned?

    - by Charles
    <form action="" method="post"> <div align="center"><legend>Add a Code</legend> <label for="code"></label> <input type="text" name="code" id="code" maxlength="10" /> <input type='button' onclick= "isAlphanumeric(document.getElementById('code'),'Your Submission Contained Invalid Characters'); isBadPhrase(document.getElementById('code'), 'Please Enter A Correct Friend Code!');" value='Check Field' /> function isAlphanumeric(elem, helperMsg){ var alphaExp = /^[0-9a-zA-Z]+$/; if(elem.value.match(alphaExp)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function isBadPhrase(elem,helperMsg){ var badPhrase=/EPW|ESW|\s/; if (elem.value.match(badPhrase)){ alert(helperMsg); elem.focus(); return false; }else{ return true; } } What is wrong here?

    Read the article

  • File descriptor limits and default stack sizes

    - by Charles
    Where I work we build and distribute a library and a couple complex programs built on that library. All code is written in C and is available on most 'standard' systems like Windows, Linux, Aix, Solaris, Darwin. I started in the QA department and while running tests recently I have been reminded several times that I need to remember to set the file descriptor limits and default stack sizes higher or bad things will happen. This is particularly the case with Solaris and now Darwin. Now this is very strange to me because I am a believer in 0 required environment fiddling to make a product work. So I am wondering if there are times where this sort of requirement is a necessary evil, or if we are doing something wrong. Edit: Great comments that describe the problem and a little background. However I do not believe I worded the question well enough. Currently, we require customers, and hence, us the testers, to set these limits before running our code. We do not do this programatically. And this is not a situation where they MIGHT run out, under normal load our programs WILL run out and seg fault. So rewording the question, is requiring the customer to change these ulimit values to run our software to be expected on some platforms, ie, Solaris, Aix, or are we as a company making it to difficult for these users to get going? Bounty: I added a bounty to hopefully get a little more information on what other companies are doing to manage these limits. Can you set these pragmatically? Should we? Should our programs even be hitting these limits or could this be a sign that things might be a bit messy under the covers? That is really what I want to know, as a perfectionist a seemingly dirty program really bugs me.

    Read the article

  • LINQ to objects: Is there

    - by Charles
    I cannot seem to find a way to have LINQ return the value from a specified accessor. I know the name of the accessors for each object, but am unsure if it is possible to pass the requested accessor as a variable or otherwise achieve the desired refactoring. Consider the following code snippet: // "value" is some object with accessors like: format, channels, language row = new List<String> { String.Join(innerSeparator, (from item in myObject.Audio orderby item.Key ascending select item.Value.format).ToArray()), String.Join(innerSeparator, (from item in myObject.Audio orderby item.Key ascending select item.Value.channels).ToArray()), String.Join(innerSeparator, (from item in myObject.Audio orderby item.Key ascending select item.Value.language).ToArray()), // ... } I'd like to refactor this into a method that uses the specified accessor, or perhaps pass a delegate, though I don't see how that could work. string niceRefactor(myObj myObject, string /* or whatever type */ ____ACCESSOR) { return String.Join(innerSeparator, (from item in myObject.Audio orderby item.Key ascending select item.Value.____ACCESSOR).ToArray()); } I have written a decent amount of C#, but am still new to the magic of LINQ. Is this the right approach? How would you refactor this?

    Read the article

  • Does unboxing just return a pointer to the value within the boxed object on the heap?

    - by Charles
    I this MSDN Magazine article, the author states (emphasis mine): Note that boxing always creates a new object and copies the unboxed value's bits to the object. On the other hand, unboxing simply returns a pointer to the data within a boxed object: no memory copy occurs. However, it is commonly the case that your code will cause the data pointed to by the unboxed reference to be copied anyway. I'm confused by the sentence I've bolded and the sentence that follows it. From everything else I've read, including this MSDN page, I've never before heard that unboxing just returns a pointer to the value on the heap. I was under the impression that unboxing would result in you having a variable containing a copy of the value on the stack, just as you began with. After all, if my variable contains "a pointer to the value on the heap", then I haven't got a value type, I've got a pointer. Can someone explain what this means? Was the author on crack? (There is at least one other glaring error in the article). And if this is true, what are the cases where "your code will cause the data pointed to by the unboxed reference to be copied anyway"? I just noticed that the article is nearly 10 years old, so maybe this is something that changed very early on in the life of .Net.

    Read the article

  • jQuery('body').text() gives different answers in different browsers

    - by Charles Anderson
    My HTML looks like this: <html> <head> <title>Test</title> <script type="text/javascript" src="jQuery.js"></script> <script type="text/javascript"> function init() { var text = jQuery('body').text(); alert('length = ' + text.length); } </script> </head> <body onload="init()">0123456789</body> </html> When I load this in Firefox, the length is reported as 10. However, in Chrome it's 11 because it thinks there's a linefeed after the '9'. In IE it's also 11, but the last character is an escape. Meanwhile, Opera thinks there are 12 characters, with the last two being CR LF. If I change the body element to include a span: <body onload="init()"><span>0123456789</span></body> and the jQuery call to: var text = jQuery('body span').text(); then all the browsers agree that the length is 10. Clearly it's the body element that's causing the issue, but can anyone explain exactly why this is happening? I'm particularly surprised because the excellent jQuery is normally browser-independent.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >