types

Why is it important to understand the difference between reference types and primitive types in Java?

I'm after a list of issues in Java that cannot be properly understood without first understanding the difference. For example: Passing parameters to methods Precisely what limitations are imposed by using "final" on a variable declaration. What == means Any more? EDIT: this question doesn't seem to make sense to people. The m...

how to make subonic convert a String to my custom Type

I tried to search for it on google but couldn't find the answer so i'll try it here. I am using Subonic and am trying to fill an object by using: Model.Object o = new Select() .From<Object>() .Where("Id") .IsEqualTo(id) .ExecuteSingle<Model.Object>(); When doing so i get the error: Objec...

TypeError (Can't convert nil into String) With Attachment_Fu

I'm handling file attachments in my Rails app with Attachment_fu, which provides a public_filename method to retrieve a file's URL. I'm using it on a model called Cover, so if I want to call the URL of an uploaded cover image, in a view I would do: <%= image_tag(@cover.public_filename) %> This works just fine when the user has the app...

c# type to handle relative and absolute URI's and local file paths

I have a use cases where I will be dealing with both local file paths (e.g. c:\foo\bar.txt) and URI's (e.g. http://somehost.com/fiz/baz). I also will be dealing with both relative and absolute paths so I need functionality like Path.Combine and friends. Is there an existing C# type I should use? The Uri type might work but at a passing ...

Java: Cyclic generic type relation doesn't allow cast from supertype (javac bug).

Hello! I encounter a totally strange behavior of the Java compiler. I can't cast a supertype to a subtype when cyclic generic type relation is involved. JUnit test case to reproduce the problem: public class _SupertypeGenericTest { interface ISpace<S extends ISpace<S, A>, A extends IAtom<S, A>> { } interface IAtom<S extends ISpac...

Conditional behaviour based on concrete type for generic class

Since my question from yesterday was perhaps not completely clear and I did not get the answer I wanted, I will try to formulate it in a more general way: Is there a way to implement special behaviour based on the actual type of an instantiated generic type either using explict conditional statements or using some kind of specialization...

Storing decimal values in SQL Server

I'm trying to figure out decimal data type of a column in the SQL server. I need to be able to store values like 15.5, 26.9, 24.7, 9.8, etc I assigned decimal(18, 0) to the column data type but this not allowing me to store these values. What is the right way to do this? Thank you ...

Help need Allocatable Array in FORTRAN

Hi, All. I'm really having trouble with Allocatable array. I have to copy all information from a file into allocatable array. The file is like this: 3 3 5 2 1 4 0 3 is the number of points other six numbers shows points on the graph in (x, y) form. So (3,5), (2, 1), (4,0) are the points. But I have problem to make these number as...

Abstract Types / Type Parameters in Scala

I am trying to write some Scala code that needs to do something like: class Test[Type] { def main { SomeFunc classOf[Type] val testVal: Type = new Type() } } and it's failing. I'm obviously not understanding something about Scala generic parameters. Clearly, the misunderstanding is that in C++, templates essen...

What is the "base class" for C# numeric value types?

Say I want to have a method that takes any kind of number, is there a base class (or some other concept) that I can use? As far as I know I have to make overloads for all the different numeric types (Int32, Int16, Byte, UInt32, Double, Float, Decimal, etc). This seems awfully tedious. Either that or use the type "object" and throw exce...

How can I check if two values in c# are equal? (Given any type of value)

I have this code here, which is intended to allow any type of arguments: public static void AreEqual(object expectedValue, object actualValue) { if (expectedValue == actualValue) { HttpContext.Current.Response.Write("Equal"); } else { HttpContext.Current.Response.Write("Not Equal"); } } If I call it using a couple of ints it do...

Working with Anonymous Types with Linq in VB, C#

Say I create two sets of tuples like so: Dim losSPResults As List(Of spGetDataResults) = m_dcDataClasses.spGetData.ToList Dim loTupleKeys = From t In losSPResults Select t.key1, t.key2 '' Query on an existing dataset: Dim loTupleExistingKeys = from t in m_losSPResults Select t.key3, t.key4 Now I want to perform set op...

[String] vs String in .NET

I used developerfusion.com to convert a snippet of my C# code to VB .NET and I noticed the String type translated into [String]. I tried Google and Searching SO to no avail so I will ask the community is there a difference between [String] and String? And if so what is/are the difference(s)? ...

Converting int to char in java

This has probably been answered else where but how do you get the character value of an int value? Specifically I'm reading a from a tcp stream and the readers .read() method returns an int. How do I get a char from this? ...

Custom Types in/with DLLImport'ed / P/Invoke'd win32 dll?

Good afternoon, i am currently wrestling with an old .dll which functionality I have to re-use in a .Net application & I came so far to import the basic/easy functions/methods that return bool etc, but some do in fact also expect (or return) an type that is declared within the .dll. How would I handle this? How would I map/create that ...

C#, accessing classes from a referenced project

In C#, I am developing several Windows Services which have some standard functionality so I have put all this common functionality into a separate referenced utility project. I have a situation where I need to create instances of business classes which reside in my Windows Service project from the utility project using Activator.CreateI...

How to turn a Type instance into a generic type argument

I basically have something like this: void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent); } Foo(typeof(Person)); The Deserialize<ty> doesn't work because it expects Deserialize<Person> instead. How do I work around this? I'd also like to understand how generics work and why it won't accept ty which is type...

Java polymorphism confusion

The question below is from Java SCJP5 book by Kathy Sierra and Bert Bates. Given a method declared as: public static <E extends Number> List<E> process(List<E> nums) A programmer wants to use the method like this: // INSERT DECLARATIONS HERE output = process(input); Which pair of declarations could be placed at // INSERT DECLARATI...

Using nibbles (4 bits variables) in windows C/C++

I'm programming network headers and a lot of protocols use 4 bits fields. Is there a convenient type I can use to represent this information? The smallest type I've found is a BYTE. I must then use a lot of binary operations to reference only a few bits inside that variable. ...

python dealing with Nonetype before cast\addition

I'm pulling a row from a db and adding up the fields (approx 15) to get a total. But some field values will be Null, which causes an error in the addition of the fields (TypeError: unsupported operand type(s) for +: 'NoneType' and 'int') Right now, with each field, I get the field value and set it to 'x#', then check if it is None and ...