Search Results

Search found 8616 results on 345 pages for 'primitive types'.

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

  • Unpacking tuple types in Scala

    - by jpalecek
    I was just wondering, can I decompose a tuple type into its components' types in Scala? I mean, something like this trait Container { type Element } trait AssociativeContainer extends Container { type Element <: (Unit, Unit) def get(x : Element#First) : Element#Second }

    Read the article

  • Design Patterns : Question about "Types"

    - by contactmatt
    Would someone please explain to me what the below paragraph means? This is a snippet from "Design Patterns: Elements of Reusable OO software" Part of an object's interface may be characterized by one type, and other parts by other types. Two objects of the same type need only share parts of their interfaces. Interfaces can contain other interfaces as subsets. - Design Patterns - Elements of Reusable OO software, pg 13

    Read the article

  • Determining if types alias to the same underlying type in C++

    - by emchristiansen
    I'd like to write a templated function which changes its behavior depending on template class types passed in. To do this, I'd like to determine the type passed in. For example, something like this: template <class T> void foo() { if (T == int) { // Sadly, this sort of comparison doesn't work printf("Template parameter was int\n"); } else if (T == char) { printf("Template parameter was char\n"); } } Is this possible?

    Read the article

  • Describing Types question

    - by user288245
    I have a bunch of types (eg. LargePlane, SmallPlane) that could be in this collection i've made, how do i print like LargePlane? I've tried like typeOf() and stuff but it doesn't work. Within like a toString()? So when i output the collection it states what type it is.

    Read the article

  • Performance surprise with "as" and nullable types

    - by Jon Skeet
    I'm just revising chapter 4 of C# in Depth which deals with nullable types, and I'm adding a section about using the "as" operator, which allows you to write: object o = ...; int? x = o as int?; if (x.HasValue) { ... // Use x.Value in here } I thought this was really neat, and that it could improve performance over the C# 1 equivalent, using "is" followed by a cast - after all, this way we only need to ask for dynamic type checking once, and then a simple value check. This appears not to be the case, however. I've included a sample test app below, which basically sums all the integers within an object array - but the array contains a lot of null references and string references as well as boxed integers. The benchmark measures the code you'd have to use in C# 1, the code using the "as" operator, and just for kicks a LINQ solution. To my astonishment, the C# 1 code is 20 times faster in this case - and even the LINQ code (which I'd have expected to be slower, given the iterators involved) beats the "as" code. Is the .NET implementation of isinst for nullable types just really slow? Is it the additional unbox.any that causes the problem? Is there another explanation for this? At the moment it feels like I'm going to have to include a warning against using this in performance sensitive situations... Results: Cast: 10000000 : 121 As: 10000000 : 2211 LINQ: 10000000 : 2143 Code: using System; using System.Diagnostics; using System.Linq; class Test { const int Size = 30000000; static void Main() { object[] values = new object[Size]; for (int i = 0; i < Size - 2; i += 3) { values[i] = null; values[i+1] = ""; values[i+2] = 1; } FindSumWithCast(values); FindSumWithAs(values); FindSumWithLinq(values); } static void FindSumWithCast(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { if (o is int) { int x = (int) o; sum += x; } } sw.Stop(); Console.WriteLine("Cast: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } static void FindSumWithAs(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = 0; foreach (object o in values) { int? x = o as int?; if (x.HasValue) { sum += x.Value; } } sw.Stop(); Console.WriteLine("As: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } static void FindSumWithLinq(object[] values) { Stopwatch sw = Stopwatch.StartNew(); int sum = values.OfType<int>().Sum(); sw.Stop(); Console.WriteLine("LINQ: {0} : {1}", sum, (long) sw.ElapsedMilliseconds); } }

    Read the article

  • How to compare nullable types?

    - by David_001
    I have a few places where I need to compare 2 (nullable) values, to see if they're the same. I think there should be something in the framework to support this, but can't find anything, so instead have the following: public static bool IsDifferentTo(this bool? x, bool? y) { return (x.HasValue != y.HasValue) ? true : x.HasValue && x.Value != y.Value; } Then, within code I have if (x.IsDifferentTo(y)) ... I then have similar methods for nullable ints, nullable doubles etc. Is there not an easier way to see if two nullable types are the same? Update: Turns out that the reason this method existed was because the code has been converted from VB.Net, where Nothing = Nothing returns false (compare to C# where null == null returns true). The VB.Net code should have used .Equals... instead.

    Read the article

  • Why shouldn't I always use nullable types in C#.

    - by Matthew Vines
    I've been searching for some good guidance on this since the concept was introduced in .net 2.0. Why would I ever want to use non-nullable data types in c#? (A better question is why wouldn't I choose nullable types by default, and only use non-nullable types when that explicitly makes sense.) Is there a 'significant' performance hit to choosing a nullable data type over its non-nullable peer? I much prefer to check my values against null instead of Guid.empty, string.empty, DateTime.MinValue,<= 0, etc, and to work with nullable types in general. And the only reason I don't choose nullable types more often is the itchy feeling in the back of my head that makes me feel like it's more than backwards compatibility that forces that extra '?' character to explicitly allow a null value. Is there anybody out there that always (most always) chooses nullable types rather than non-nullable types? Thanks for your time,

    Read the article

  • Using nullable types in C#

    - by Martin Brown
    I'm just interested in people's opinions. When using nullable types in C# what is the best practice way to test for null: bool isNull = (i == null); or bool isNull = !i.HasValue; Also when assigning to a non-null type is this: long? i = 1; long j = (long)i; better than: long? i = 1; long j = i.Value;

    Read the article

  • Using Scala structural types with abstract types

    - by Joshua Hartman
    I'm trying to define a structural type defining anything that has an "add" method (for instance, a java collection or a java map). Using this, I want to define a few higher order functions that operate on a certain collection object GenericTypes { type GenericCollection[T] = { def add(value: T): java.lang.Boolean} } import GenericTypes._ trait HigherOrderFunctions[T, CollectionType[X] <: GenericCollection[X]] { def map[V](fn: (T) => V): CollectionType[V] .... } class RichJList[T](list: List[T]) extends HigherOrderFunctions[T, java.util.List] This does not compile with the following error error: Parameter type in structural refinement may not refer to abstract type defined outside that same refinement I tried removing the parameter on GenericCollection and putting it on the method: object GenericTypes { type GenericCollection = { def add[T](value: T): java.lang.Boolean} } import GenericTypes._ trait HigherOrderFunctions[T, CollectionType[X] <: GenericCollection] class RichJList[T](list: List[T]) extends HigherOrderFunctions[T, java.util.List] but I get another error: error: type arguments [T,java.util.List] do not conform to trait HigherOrderFunctions's type parameter bounds [T,CollectionType[X] <: org.scala_tools.javautils.j2s.GenericTypes.GenericCollection] Can anyone give me some advice on how to use structural typing with abstract typed parameters in Scala? Or how to achieve what I'm looking to accomplish? Thanks so much!

    Read the article

  • Java Incompatible Types Boolean Int

    - by ikurtz
    i have the following class: public class NewGameContract { public boolean HomeNewGame = false; public boolean AwayNewGame = false; public boolean GameContract(){ if (HomeNewGame && AwayNewGame){ return true; } else { return false; } } } when i try to use it like so: if (networkConnection){ connect4GameModel.newGameContract.HomeNewGame = true; boolean status = connect4GameModel.newGameContract.GameContract(); switch (status){ case true: break; case false: break; } return; } i am getting the error: incompatible types found: boolean required: int on the following switch (status) code. what am i doing wrong please?

    Read the article

  • C: Incompatible types?

    - by Airjoe
    #include <stdlib.h> #include <stdio.h> struct foo{ int id; char *bar; char *baz[6]; }; int main(int argc, char **argv){ struct foo f; f.id=1; char *qux[6]; f.bar=argv[0]; f.baz=qux; // Marked line return 1; } This is just some test code so ignore that qux doesn't actually have anything useful in it. I'm getting an error on the marked line, incompatible types when assigning to type ‘char *[6]’ from type ‘char **’ but both of the variables are defined as char *[6] in the code. Any insight?

    Read the article

  • Java Switch Incompatible Types Boolean Int

    - by ikurtz
    i have the following class: public class NewGameContract { public boolean HomeNewGame = false; public boolean AwayNewGame = false; public boolean GameContract(){ if (HomeNewGame && AwayNewGame){ return true; } else { return false; } } } when i try to use it like so: if (networkConnection){ connect4GameModel.newGameContract.HomeNewGame = true; boolean status = connect4GameModel.newGameContract.GameContract(); switch (status){ case true: break; case false: break; } return; } i am getting the error: incompatible types found: boolean required: int on the following switch (status) code. what am i doing wrong please?

    Read the article

  • Incompatible Types in Initialization

    - by jack
    I have the following code in a subroutine that produces an incompatible types in initialization error on the varVal library in the subroutine evaluateExpression: NSDictionary *varVal; for (int i=0; i<varCount; i++) { [varVal setObject:[(i+1)*2 stringValue] forKey:[i stringValue]]; } double result =[[self brain] evaluateExpression:[[self brain] expression] usingVariableValues:varVal]; My subroutine declaration in the brain.h file is: +(double)evaluateExpression:(id)anExpression usingVariableValues:(NSDictionary *)variables; I'd appreciate any help.

    Read the article

  • Ubiquitous Language and Custom types

    - by EdvRusj
    Note that my question is referring to those attributes that even on their own already represent a concept ( ie on their own provide a cohesive meaning ). Thus such attribute needs no additional functional support and as such is self-contained. I'm also well-aware that even with self-contained attributes the custom types may prove beneficial ( for example, they give the ability to add new behavior later, when business requirements change ). Thus, my question focuses only on whether custom types for self-contained attributes really enrich Ubiquitous Language UL a) I've read that in most cases, even simple, self-contained attributes should have custom, more descriptive types rather than basic value types ( double, string ... ), because among other things, descriptive types add to the UL, while the use of basic types instead weakens the language. I understand the importance of UL, but how does having a basic type for a self-contained attribute weaken the language, since with self-contained attributes the name of the attribute already adequately describes the concept and thus contributes to the UL vocabulary? For example, the term person_age already adequately explains the concept of quantifying the number of years a person has: class Person { string person_age; } so what could we possibly gain by also introducing the term ThingAge to the UL: class person { ThingAge person_age; } thanks

    Read the article

  • Delphi - E2010 Incompatible types: 'Integer' and 'Char' - Any ideas

    - by zeencat
    I've been tasked with porting a legacy Delphi application over to C# .Net. The original delphi developer left several months before I was hired. I'm receiving the E2010 Incompatible types: 'Integer' and 'Char' error for the below method. I'm trying to compile the application within the Delphi 2007 IDE, I've been told that original application is either Delphi 4 or 5 if that helps any. I understand what the error is telling me but I don't understand why\how it is applied to the code snippet below. Any help\direction would be greatly appreciated. Thanks in advance function StrIComp_JOH_PAS_1(const Str1, Str2: PChar): Integer; var Ch1, Ch2 : Char; Offset : Integer; PStr : PChar; begin; PStr := Str1; Offset := Str2 - PStr; repeat Ch1 := Upper[PStr^]; Ch2 := Upper[PStr[Offset]]; if (Ch1 = #0) or (Ch1 <> Ch2) then Break; Inc(PStr); until False; Result := Integer(Ch1) - Integer(Ch2); end;

    Read the article

  • Imlpementations of an Interface with Different Types?

    - by b3njamin
    Searched as best I could but unfortunately I've learned nothing relevant; basically I'm trying to work around the following problem in C#... For example, I have three possible references (refA, refB, refC) and I need to load the correct one depending on a configuration option. So far however I can't see a way of doing it that doesn't require me to use the name of said referenced object all through the code (the referenced objects are provided, I can't change them). Hope the following code makes more sense: public ??? LoadedClass; public Init() { /* load the object, according to which version we need... */ if (Config.Version == "refA") { Namespace.refA LoadedClass = new refA(); } else if (Config.Version == "refB") { Namespace.refB LoadedClass = new refB(); } else if (Config.Version == "refC") { Namespace.refC LoadedClass = new refC(); } Run(); } private void Run(){ { LoadedClass.SomeProperty... LoadedClass.SomeMethod(){ etc... } } As you can see, I need the Loaded class to be public, so in my limited way I'm trying to change the type 'dynamically' as I load in which real class I want. Each of refA, refB and refC will implement the same properties and methods but with different names. Again, this is what I'm working with, not by my design. All that said, I tried to get my head around Interfaces (which sound like they're what I'm after) but I'm looking at them and seeing strict types - which makes sense to me, even if it's not useful to me. Any and all ideas and opinions are welcome and I'll clarify anything if necessary. Excuse any silly mistakes I've made in the terminology, I'm learning all this for the first time. I'm really enjoying working with an OOP language so far though - coming from PHP this stuff is blowing my mind :-)

    Read the article

  • SQL SERVER – 2000 – DBCC SQLPERF(waitstats) – Wait Type – Day 24 of 28

    - by pinaldave
    I have received many comments, email, suggestions and motivations for my current series of wait types and wait statistics. One of the questions which I keep on receiving almost every other day is whether all of the discussions I have presented so far are also applicable to SQL Server 2000. Additionally, I receive another question asking me if wait statistics matters in SQL Server 2000. If it is, then the asker wants to know how to measure wait types for SQL Server 2000. In SQL Server, you can run the following command to get a list of all the wait types: DBCC SQLPERF(waitstats) The query above will work in SQL Server 2005/2008/R2  because of backup compatibility. As you might have noticed, I have been discussing everything keeping SQL Server 2005+ in mind, but I have given little consideration on SQL Server 2000. However, I am pretty sure that most of the suggestions I have provided are applicable to SQL Server 2000. The wait types I have been discussing mostly exist in SQL Server 2000 as well. But the difference of the 2000 version is that it gets late recent releases, but it is worth it. Wait types are very essential to measure performance bottleneck. Because of this, I do not have to state that I am big fan of them just so I could identify performance bottleneck. Please read all the post in the Wait Types and Queue series. Note: The information presented here is from my experience and there is no way that I claim it to be accurate. I suggest reading Book OnLine for further clarification. All the discussion of Wait Stats in this blog is generic and varies from system to system. It is recommended that you test this on a development server before implementing it to a production server. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQL Wait Stats, SQL Wait Types, T SQL, Technology

    Read the article

  • Entity Association Mapping with Code First Part 1 : Mapping Complex Types

    - by mortezam
    Last week the CTP5 build of the new Entity Framework Code First has been released by data team at Microsoft. Entity Framework Code-First provides a pretty powerful code-centric way to work with the databases. When it comes to associations, it brings ultimate flexibility. I’m a big fan of the EF Code First approach and am planning to explain association mapping with code first in a series of blog posts and this one is dedicated to Complex Types. If you are new to Code First approach, you can find a great walkthrough here. In order to build a solid foundation for our discussion, we will start by learning about some of the core concepts around the relationship mapping.   What is Mapping?Mapping is the act of determining how objects and their relationships are persisted in permanent data storage, in our case, relational databases. What is Relationship mapping?A mapping that describes how to persist a relationship (association, aggregation, or composition) between two or more objects. Types of RelationshipsThere are two categories of object relationships that we need to be concerned with when mapping associations. The first category is based on multiplicity and it includes three types: One-to-one relationships: This is a relationship where the maximums of each of its multiplicities is one. One-to-many relationships: Also known as a many-to-one relationship, this occurs when the maximum of one multiplicity is one and the other is greater than one. Many-to-many relationships: This is a relationship where the maximum of both multiplicities is greater than one. The second category is based on directionality and it contains two types: Uni-directional relationships: when an object knows about the object(s) it is related to but the other object(s) do not know of the original object. To put this in EF terminology, when a navigation property exists only on one of the association ends and not on the both. Bi-directional relationships: When the objects on both end of the relationship know of each other (i.e. a navigation property defined on both ends). How Object Relationships Are Implemented in POCO domain models?When the multiplicity is one (e.g. 0..1 or 1) the relationship is implemented by defining a navigation property that reference the other object (e.g. an Address property on User class). When the multiplicity is many (e.g. 0..*, 1..*) the relationship is implemented via an ICollection of the type of other object. How Relational Database Relationships Are Implemented? Relationships in relational databases are maintained through the use of Foreign Keys. A foreign key is a data attribute(s) that appears in one table and must be the primary key or other candidate key in another table. With a one-to-one relationship the foreign key needs to be implemented by one of the tables. To implement a one-to-many relationship we implement a foreign key from the “one table” to the “many table”. We could also choose to implement a one-to-many relationship via an associative table (aka Join table), effectively making it a many-to-many relationship. Introducing the ModelNow, let's review the model that we are going to use in order to implement Complex Type with Code First. It's a simple object model which consist of two classes: User and Address. Each user could have one billing address. The Address information of a User is modeled as a separate class as you can see in the UML model below: In object-modeling terms, this association is a kind of aggregation—a part-of relationship. Aggregation is a strong form of association; it has some additional semantics with regard to the lifecycle of objects. In this case, we have an even stronger form, composition, where the lifecycle of the part is fully dependent upon the lifecycle of the whole. Fine-grained domain models The motivation behind this design was to achieve Fine-grained domain models. In crude terms, fine-grained means “more classes than tables”. For example, a user may have both a billing address and a home address. In the database, you may have a single User table with the columns BillingStreet, BillingCity, and BillingPostalCode along with HomeStreet, HomeCity, and HomePostalCode. There are good reasons to use this somewhat denormalized relational model (performance, for one). In our object model, we can use the same approach, representing the two addresses as six string-valued properties of the User class. But it’s much better to model this using an Address class, where User has the BillingAddress and HomeAddress properties. This object model achieves improved cohesion and greater code reuse and is more understandable. Complex Types: Splitting a Table Across Multiple Types Back to our model, there is no difference between this composition and other weaker styles of association when it comes to the actual C# implementation. But in the context of ORM, there is a big difference: A composed class is often a candidate Complex Type. But C# has no concept of composition—a class or property can’t be marked as a composition. The only difference is the object identifier: a complex type has no individual identity (i.e. no AddressId defined on Address class) which make sense because when it comes to the database everything is going to be saved into one single table. How to implement a Complex Types with Code First Code First has a concept of Complex Type Discovery that works based on a set of Conventions. The convention is that if Code First discovers a class where a primary key cannot be inferred, and no primary key is registered through Data Annotations or the fluent API, then the type will be automatically registered as a complex type. Complex type detection also requires that the type does not have properties that reference entity types (i.e. all the properties must be scalar types) and is not referenced from a collection property on another type. Here is the implementation: public class User{    public int UserId { get; set; }    public string FirstName { get; set; }    public string LastName { get; set; }    public string Username { get; set; }    public Address Address { get; set; }} public class Address {     public string Street { get; set; }     public string City { get; set; }            public string PostalCode { get; set; }        }public class EntityMappingContext : DbContext {     public DbSet<User> Users { get; set; }        } With code first, this is all of the code we need to write to create a complex type, we do not need to configure any additional database schema mapping information through Data Annotations or the fluent API. Database SchemaThe mapping result for this object model is as follows: Limitations of this mappingThere are two important limitations to classes mapped as Complex Types: Shared references is not possible: The Address Complex Type doesn’t have its own database identity (primary key) and so can’t be referred to by any object other than the containing instance of User (e.g. a Shipping class that also needs to reference the same User Address). No elegant way to represent a null reference There is no elegant way to represent a null reference to an Address. When reading from database, EF Code First always initialize Address object even if values in all mapped columns of the complex type are null. This means that if you store a complex type object with all null property values, EF Code First returns a initialized complex type when the owning entity object is retrieved from the database. SummaryIn this post we learned about fine-grained domain models which complex type is just one example of it. Fine-grained is fully supported by EF Code First and is known as the most important requirement for a rich domain model. Complex type is usually the simplest way to represent one-to-one relationships and because the lifecycle is almost always dependent in such a case, it’s either an aggregation or a composition in UML. In the next posts we will revisit the same domain model and will learn about other ways to map a one-to-one association that does not have the limitations of the complex types. References ADO.NET team blog Mapping Objects to Relational Databases Java Persistence with Hibernate

    Read the article

  • iPhone NSXMLParser parsing string and storing in a NSNumber variable and different data types

    - by anubhav
    Hi, I am trying to parse a XML File using NSXMLParser, I also have a Container class, in which I have a few instance variables. One of the elements that I am trying to parse in the XML is: <book sn="32.859669048339128" pn="-116.917800670489670"> I am trying to save the value of sn and pn in an instance variable of object Container: NSNumber *sn, NSNumber *pn. I want it so that when my parser get the attributeValues it can save it as a Double (or float) in those NSNumber pointers. Right now, all it does it just saves a string to the NSNumber. The Parser Code looks like this: if([elementName isEqualToString:@"book"]){ container = [[Container alloc] init]; container.sn=[attributeDict objectForKey:@"sn"]; container.pn=[attributeDict objectForKey:@"pn"]; } I want it so that the type of container.sn is initialized to a float or double. Any ideas how to do this? Thanks in advance!

    Read the article

  • Complex data types in WCF?

    - by Hojou
    I've run into a problem trying to return an object that holds a collection of childobjects that again can hold a collection of grandchild objects. I get an error, 'connection forcibly closed by host'. Is there any way to make this work? I currently have a structure resembling this: pseudo code: Person: IEnumerable<Order> Order: IEnumberable<OrderLine> All three objects have the DataContract attribute and all public properties i want exposed (including the IEnumerable's) have the DataMember attribute. I have multiple OperationContract's on my service and all the methods returning a single object OR an IEnumerable of an object works perfectly. It's only when i try to nest IEnumerable that it turns bad. Also in my client service reference i picked the generic list as my collection type. I just want to emphasize, only one of my operations/methods fail with this error - the rest of them work perfectly. EDIT (more detailed error description): [SocketException (0x2746): An existing connection was forcibly closed by the remote host] [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.] [WebException: The underlying connection was closed: An unexpected error occurred on a receive.] [CommunicationException: An error occurred while receiving the HTTP response to http://myservice.mydomain.dk/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.] I tried looking for logs but i can't find any... also i'm using a WSHttpBinding and an http endpoint.

    Read the article

  • Defining recursive algebraic data types in XML XSD

    - by Ben Challenor
    Imagine I have a recursive algebraic data type like this (Haskell syntax): data Expr = Zero | One | Add Expr Expr | Mul Expr Expr I'd like to represent this in XML, and I'd like an XSD schema for it. I have figured out how to achieve this syntax: <Expr> <Add> <Expr> <Zero/> </Expr> <Expr> <Mul> <Expr> <One/> </Expr> <Expr> <Add> <Expr> <One/> </Expr> <Expr> <One/> </Expr> </Add> </Expr> </Mul> </Expr> </Add> </Expr> with this schema: <xs:complexType name="Expr"> <xs:choice minOccurs="1" maxOccurs="1"> <xs:element minOccurs="1" maxOccurs="1" name="Zero" type="Zero" /> <xs:element minOccurs="1" maxOccurs="1" name="One" type="One" /> <xs:element minOccurs="1" maxOccurs="1" name="Add" type="Add" /> <xs:element minOccurs="1" maxOccurs="1" name="Mul" type="Mul" /> </xs:choice> </xs:complexType> <xs:complexType name="Zero"> <xs:sequence> </xs:sequence> </xs:complexType> <xs:complexType name="One"> <xs:sequence> </xs:sequence> </xs:complexType> <xs:complexType name="Add"> <xs:sequence> <xs:element minOccurs="2" maxOccurs="2" name="Expr" type="Expr" /> </xs:sequence> </xs:complexType> <xs:complexType name="Mul"> <xs:sequence> <xs:element minOccurs="2" maxOccurs="2" name="Expr" type="Expr" /> </xs:sequence> </xs:complexType> But what I really want is this syntax: <Add> <Zero/> <Mul> <One/> <Add> <One/> <One/> </Add> </Mul> </Add> Is this possible? Thanks!

    Read the article

  • How to aggregate over few types with linq?

    - by Shimmy
    Can someone help me translate the following to one liner: Dim items As New List(Of Object) For Each c In ph.Contacts items.Add(New With {.Type = "Contact", .Id = c.ContactId, .Title = c.Title}) Next For Each c In ph.Persons items.Add(New With {.Type = "Person", .Id = c.PersonId, .Title = c.Title}) Next For Each c In ph.Jobs items.Add(New With {.Type = "Job", .Id = c.JobId, .Title = c.Title}) Next Is it possible to merge them all into one query or method line, I don't really care if this will be done with something other than linq, I am just looking for a more efficient way as I have a long list coming ahead, and the aggregating list will be strongly-typed using Dim list = blah blah

    Read the article

  • pl/sql object types "ORA-06530: Reference to uninitialized composite" error

    - by mutoss
    hi, i have a type as follows: CREATE OR REPLACE TYPE tbusiness_inter_item_bag AS OBJECT ( item_id NUMBER, system_event_cd VARCHAR2 (20), CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT ); CREATE OR REPLACE TYPE BODY tbusiness_inter_item_bag AS CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT AS BEGIN RETURN; END; END; when i execute the following script, i got a "Reference to uninitialized composite" error, which is imho quite suitable. DECLARE item tbusiness_inter_item_bag; BEGIN item.system_event_cd := 'ABC'; END; This also raises the same error: item.item_id := 3; But if i change my object type into: CREATE OR REPLACE TYPE tbusiness_inter_item_bag AS OBJECT ( item_id NUMBER(1), system_event_cd VARCHAR2 (20), CONSTRUCTOR FUNCTION tbusiness_inter_item_bag RETURN SELF AS RESULT ); then the last statement raises no more error (where my "item" is still uninitialized): item.item_id := 3; Shouldn't i get the same ORA-06530 error? ps: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

    Read the article

  • Raw types and subtyping

    - by Dmitrii
    We have generic class SomeClass<T>{ } We can write the line: SomeClass s= new SomeClass<String>(); It's ok, because raw type is supertype for generic type. But SomeClass<String> s= new SomeClass(); is correct to. Why is it correct? I thought that type erasure was before type checking, but it's wrong. From Hacker's Guide to Javac When the Java compiler is invoked with default compile policy it performs the following passes: parse: Reads a set of *.java source files and maps the resulting token sequence into AST-Nodes. enter: Enters symbols for the definitions into the symbol table. process annotations: If Requested, processes annotations found in the specified compilation units. attribute: Attributes the Syntax trees. This step includes name resolution, type checking and constant folding. flow: Performs data ow analysis on the trees from the previous step. This includes checks for assignments and reachability. desugar: Rewrites the AST and translates away some syntactic sugar. generate: Generates Source Files or Class Files. Generic is syntax sugar, hence type erasure invoked at 6 pass, after type checking, which invoked at 4 pass. I'm confused.

    Read the article

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