Search Results

Search found 332 results on 14 pages for 'baz'.

Page 4/14 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why can't I enforce derived classes to have parameterless constructors?

    - by FrisbeeBen
    I am trying to do the following: public class foo<T> where T : bar, new() { public foo() { _t = new T(); } private T _t; } public abstract class bar { public abstract void someMethod(); // Some implementation } public class baz : bar { public overide someMethod(){//Implementation} } And I am attempting to use it as follows: foo<baz> fooObject = new foo<baz>(); And I get an error explaining that 'T' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic type or method. I fully understand why this must be, and also understand that I could pass a pre-initialized object of type 'T' in as a constructor argument to avoid having to 'new' it, but is there any way around this? any way to enforce classes that derive from 'bar' to supply parameterless constructors?

    Read the article

  • Dynamic reference to resource files in C#

    - by Joda
    I have an application on which I am implementing localization. I now need to dynamically reference a name in the resouce file. assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world" normally, I will refer as: String result =Login.foo; and result=="hello"; my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz". I need something like: Login["foo"]; Does anyone know if there is any way to dynamically reference a string in a resource file?

    Read the article

  • Best way to access nested data structures?

    - by Blackshark
    I would like to know what the best way (performance wise) to access a large data structure is. There are about hundred ways to do it but what is the most accessible for the compiler to optimize? One can access a value by foo[someindex].bar[indexlist[i].subelement[j]].baz[0] or create some pointer aliases like sometype_t* tmpfoo = &foo[someindex]; tmpfoo->bar[indexlist[i].subelement[j]].baz[0] or create reference aliases like sometype_t &tmpfoo = foo[someindex]; tmpfoo.bar[indexlist[i].subelement[j]].baz[0] and so forth...

    Read the article

  • When should method overloads be refactored?

    - by Ben Heley
    When should code that looks like: DoThing(string foo, string bar); DoThing(string foo, string bar, int baz, bool qux); ... DoThing(string foo, string bar, int baz, bool qux, string more, string andMore); Be refactored into something that can be called like so: var doThing = new DoThing(foo, bar); doThing.more = value; doThing.andMore = otherValue; doThing.Go(); Or should it be refactored into something else entirely? In the particular case that inspired this question, it's a public interface for an XSLT templating DLL where we've had to add various flags (of various types) that can't be embedded into the string XML input.

    Read the article

  • Case Class naming convention

    - by KChaloux
    In my recent adventures in Scala, I've found case classes to be a really nice alternative to enums when I need to include a bit of logic or several values with them. I often find myself writing structures that look like this, however: object Foo{ case class Foo(name: String, value: Int, other: Double) val BAR = Foo("bar", 1, 1.0) val BAZ = Foo("baz", 2, 1.5) val QUUX = Foo("quux", 3, 1.75) } I'm primarily worried here about the naming of the object and the case class. Since they're the same thing, I end up with Foo.Foo to get to the inner class. Would it be wise to name the case class something along the lines of FooCase instead? I'm not sure if the potential ambiguity might mess with the type system if I have to do anything with subtypes or inheritance.

    Read the article

  • What are the Consequences for using Relative Location Headers?

    - by Alan Storm
    According to the spec, Location headers used in a redirect require a server name HTTP/1.1 301 Moved Permanently ... Location: http://example.com/foo/baz/bar However, in 2012, most web browsers will recognize a relative path and redirect you to the new location using the original server name HTTP/1.1 301 Moved Permanently ... Location: /foo/baz/bar Are there any negative/surprising consequences to using the relative URLs in the Location headers? My particular concern is how Google/search-engines will interpret this, but if there's anything else I'm not thinking about I'd love to hear it.

    Read the article

  • Line-length-tolerant XML diff

    - by Jon Skeet
    I've looked at the answers to this question, and unfortunately none of them has helped me so far. Not to beat about the bush, the second edition of C# in Depth is now in copy edit. I want to be able to see what the copy editor's done really easily, so I can reject or accept his changes. We're using a modified form of docbook, but I'm happy enough looking at the raw XML source. All fine so far - except that when the copy editor makes a change, that can change the line wrapping. So something that used to read: <para>Foo bar baz second line</para> now reads <para>Foo bar grontle baz second line</para> Now the real change here is the insertion of "grontle". I don't care that "baz" has moved from the first line to the second line... but all the diff tools I've seen do. I realise that one option would be to reformat the whole document (or possibly just whole paragraphs) into single lines... but that's then really hard to read, because diff tools don't wrap when they're displaying. I'm sure I can manage with the tools I've got, but if anyone knows of anything better, I'd be really glad to hear about it. I suspect my publishers would too :) (I've included the Windows tag here because I'd really need it to be available on Windows. I'd like to hear about any non-Windows software too, but only in case I could help to build it on Windows :)

    Read the article

  • Unfold vCard lines in shell

    - by l0b0
    vCard lines can be folded by inserting "\r\n " (that's a space at the start of the new line), but I'm struggling to unfold them with the line-oriented GNU tools (sed, cut). Any ideas? Effectively, from the string foo bar baz ban bay bal it must return foobar baz banbaybal

    Read the article

  • Result set mapping in Grails / GORM

    - by armandino
    I want to map the result of a native SQL query to a simple bean in grails, similar to what the @SqlResultSetMapping annotation does. For example, given a query select x.foo, y.bar, z.baz from //etc... map the result to class FooBarBaz { String foo String bar String baz } Can anyone provide an example of how to do this in grails? Thanks in advance.

    Read the article

  • How to split a git repository while preserving subdirectories?

    - by Thomas
    What I want is similar to this question. However, I want the directory that is split into a separate repo to remain a subdirectory in that repo: I have this: foo/ .git/ bar/ baz/ qux/ And I want: foo/ .git/ bar/ baz/ quux/ .git/ qux/ # Note: still a subdirectory How to do this in git? I could use the method from this answer if there is some way to move all the new repo's contents into a subdirectory, throughout history.

    Read the article

  • awk/sed/bash to merge data

    - by Kyle
    Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution.

    Read the article

  • What does "str indices must be integers" mean?

    - by digitala
    I'm working with dicts in jython which are created from importing/parsing JSON. Working with certain sections I see the following message: TypeError: str indices must be integers This occurs when I do something like: if jsondata['foo']['bar'].lower() = 'baz': ... Where jsondata looks like: {'foo': {'bar':'baz'} } What does this mean, and how do I fix it?

    Read the article

  • awk/sed/bash to merge/concatenate data

    - by Kyle
    Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution.

    Read the article

  • Java return to position N in call stack.

    - by Finbarr
    Using the return keyword in Java code will return execution to the last piece of calling code in the call stack. If object foo calls baz.bar(), the return keyword in the bar method will continue code execution in foo. Let's say I have object foo that calls foofoo that calls foofoofoo in the above scenario, and foofoofoo calls baz.bar(). Is there anyway in Java to use the return keyword, or something else, so that the code in the bar method can return all the way back up to foo? (WITHOUT THROWING AN EXCEPTION)

    Read the article

  • Regex AND operator

    - by user366735
    Based on this answer http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator I tried the following on http://regexpal.com/ but was unable to get it to work. What am missing? Does javascript not support it? Regex: (?=foo)(?=baz) String: foo,bar,baz

    Read the article

  • Multiple instance_of?

    - by c00lryguy
    How would I make Object#instance_of? accept multiple arguments so that something like the below example would work? class Foo; end class Bar; end class Baz; end my_foo = Foo.new my_bar = Bar.new my_baz = Baz.new my_foo.instance_of?(Foo, Bar) # => true my_bar.instance_of?(Foo, Bar) # => true my_baz.instance_of?(Foo, Bar) # => false

    Read the article

  • Linq grouping question

    - by Mike C.
    I have the following objects in a collection: Transaction: Type = "Widget" Date = "3/1/2011" Name = "Foo" Transaction: Type = "Widget" Date = "3/4/2011" Name = "Bar" Transaction: Type = "Gadget" Date = "3/2/2011" Name = "Baz" Transaction: Type = "Gizmo" Date = "3/1/2011" Name = "Who" Transaction: Type = "Gizmo" Date = "3/2/2011" Name = "What" Transaction: Type = "Gizmo" Date = "3/6/2011" Name = "When" I want to end up with the following, grouped by Type. If there are multiple, return only the first one chronologically by date. Transaction: Type = "Widget" Date = "3/1/2011" Name = "Foo" Transaction: Type = "Gadget" Date = "3/2/2011" Name = "Baz" Transaction: Type = "Gizmo" Date = "3/1/2011" Name = "Who"

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >