Of course they maybe used together. (do not understand what the word program meant in the question context)
However, do not put them together in an array. In fact, any collection, including an array, should hold only 1 kind of objects. (the word kind means a base class and its derived subclasses, the same interface, or the same primitive types).
Putting more than 1 kind of objects in an array is making troubles for yourself, putting more than one class of objects in an array is an acceptable practice.
Another thing to look out for, if a primitive type is always go with a reference type, or most of time, being used, or being passed to another method, you may have a new class to be designed. You should put them together into a new class.
If you have a method need to return a primitive and a reference type, you may have another class design to do as well, or the method is doing too many things (one is the principle!). 1 pair of int and Person may not be a problem.
But when you have more than 10 pairs... Do you have 2 arrays, one to hold the integers, one to hold Person? Or you have 1 array to hold both (the odd element is always the int, and the even is the Person - big mistake). Now just image that, oh by the way, you will need a String (message text) go with the int and the Person....
Yes you can store non primitive data type variables in an array. String is a non primitive data type. You can declare a string array as: String a[]=new String[10];
An array is a primitive data type. It is the element type that may or may not be primitive.
Only if the non-primitive data types are actually controls, such as an array of label controls, or an array of edit boxes. However, a control array is still an array. The only difference is that the values will likely be resource handles (objects that refer or point to the actual object which will be stored elsewhere in memory) rather than an actual value itself. That is, an array of primitive data types stores the actual value in the array itself.
No, it can be array, structure or union as well.
Depends on the context of the question you were asking from, there are 2 distinct answers: Yes and NO. In the narrowest definition, any array is NOT a primitive data type in C#. Hence a string array is NOT a primitive data type in that context. A string itself, however, is a primitive data type. Some developers would like to extend the definition of "primitives" into the arrays, collections, and Enumeration. Thus, in this context, an array of string IS a primitive data type.
Yes you can store non primitive data type variables in an array. String is a non primitive data type. You can declare a string array as: String a[]=new String[10];
Arrays are objects in Java that store multiple variables of the same type. Arrays can hold either primitives or object references, but the array itself will always be an object on the heap, even if the array is declared to hold primitive elements. In other words, there is no such thing as a primitive array, but you can make an array of primitives. Arrays are declared by stating the type of element the array will hold, which can be an object or a primitive, followed by square brackets to the left or right of the identifier. Declaring an array of primitives: int[] Values; // brackets before name (recommended) int Values []; // brackets after name (legal but less readable) // spaces between the name and [] legal, but bad Declaring an array of object references: Ferrari[] Ferraris; // Recommended Ferrari Ferraris[]; // Legal but less readable When declaring an array reference, you should always put the array brackets immediately after the declared type, rather than after the identifier (variable name). That way, anyone reading the code can easily tell that, for example, Values is a reference to an int array object, and not an int primitive.
An array is a primitive data type. It is the element type that may or may not be primitive.
Struct or array.
Arrays are reference type. array values are always pass by reference.
Only if the non-primitive data types are actually controls, such as an array of label controls, or an array of edit boxes. However, a control array is still an array. The only difference is that the values will likely be resource handles (objects that refer or point to the actual object which will be stored elsewhere in memory) rather than an actual value itself. That is, an array of primitive data types stores the actual value in the array itself.
A primitive data structure is generally a basic structure that is usually built into the language, such as an integer, an array or a linked-list.A non-primitive data structure is built out of primitive data structures linked together in meaningful ways, such as a binary search tree, AVL Tree, Hashtable, etc.
No, it can be array, structure or union as well.
No, it's not. But it can be based on primitive data types (int, char, long, double and so on).
Depends on the context of the question you were asking from, there are 2 distinct answers: Yes and NO. In the narrowest definition, any array is NOT a primitive data type in C#. Hence a string array is NOT a primitive data type in that context. A string itself, however, is a primitive data type. Some developers would like to extend the definition of "primitives" into the arrays, collections, and Enumeration. Thus, in this context, an array of string IS a primitive data type.
Yes. Arrays are objects in Java that store multiple variables of the same type. Arrays can hold either primitives or object references, but the array itself will always be an object on the heap, even if the array is declared to hold primitive elements. In other words, there is no such thing as a primitive array, but you can make an array of primitives
Arrays are objects in Java that store multiple variables of the same type. Arrays can hold either primitives or object references, but the array itself will always be an object on the heap, even if the array is declared to hold primitive elements. In other words, there is no such thing as a primitive array, but you can make an array of primitives. Arrays are declared by stating the type of element the array will hold, which can be an object or a primitive, followed by square brackets to the left or right of the identifier. Declaring an array of primitives: int[] Values; // brackets before name (recommended) int Values []; // brackets after name (legal but less readable)