Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to write this in C#?
Intent intent = new Intent(Intent.ActionSendMultiple, Android.Provider.MediaStore.Images.Media.ExternalContentUri);
handler(intent);
....
void handler(Intent intent)
{
ArrayList<Uri> imageUris = intent.GetParcelableArrayListExtra(Intent.ExtraStream);
...
}
ArrayList is available is c# but it does not have a generic (<T>) form. ArrayList is a list of objects.
What you want is System.Collections.Generic.List<T>
EDIT : In response to comments, try this;
List<Uri> imageUris = new List<Uri>(intent.GetIntegerArrayListExtra(Intent.ExtraStream));
Easy, just use List<Uri>. It's also faster than ArrayList.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Sorry, I am EXTREMELY NEW to C#. I do not have much experience with code, so keep that in mind. I want to have my console application do something like this example:
Who is the best?
(Text be written here^)
IF the answer is tim, then write "Your right!"
If the answer is NOT tim, then write "Wrong!" and the code doews not advance until the word "tim" is put in
You can use Console.WriteLine to write out text, and Console.ReadLine() to read in the response from the user. A while loop can be used to keep looping until the reponse matches.
I totally agree with the other answers and comments, but for convenience here is the code
public class Program
{
public static void Main()
{
Console.WriteLine("Who is the best?");
var answer = Console.ReadLine();
if (answer.Equals("tim")){
Console.WriteLine("You're right!")
} else {
Console.WriteLine("Wrong!")
}
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How to save everything from ArrayList to .txt file in c#, then on starting WPF application load it?
static void SaveArray()
{
ArrayList myArray = new ArrayList();
myArray.Add("First");
myArray.Add("Second");
myArray.Add("Third");
myArray.Add("and more");
StreamWriter sw= File.CreateText(#"C:\file.txt");
foreach (string item in myArray)
{
sw.WriteLine(item);
}
sw.Close();
}
and you shouldn't use arraylist not because its 2013 ,but because arraylist boxing each item in the array, where List store the type also.
this cost less in memory use.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a typed dataset with a column called price, which is of string datatype. And I'm showing this via ultrgrid/datagrid
How can I show the price in number format.
For example: price ==123456
in the grid it should be like 12,354,56
Try this
var a = price.ToString("##,###,##");
Reference
Custom Numeric Format Strings!
Look at some of the related links to the right of the screen. Some of them even ask the same question as you !
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need remove all items step by step from list and add removed items to another list, but I need max effective and hithperformance operation. What is whe best practics?
You could use this code and hope that framework'll do the best for you:
public static void MoveItems<T>(List<T> list1, List<T> list2)
{
list2.AddRange(list1);
list1.Clear();
}
list2 = list1.ToList();
list1.Clear();
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to generate a custom xml doc, using this class:
[CollectionDataContract(Name="Applications", ItemName="Application")]
public class ApplicationNamesList : List<string> { }
The xml output im aming at should look like this
<Applications>
<Application>...</Application>
<Application>...</Application>
<Application>...</Application>
</Applications>
But once I have a List<string> object and try and cast this to ApplicationNamesList i get an InvalidCastException.
Is there something basic im not getting here?
A List<string> simply isn't a ApplicationNamesList. You would need to do something like this:
var result = new ApplicationNamesList();
result.AddRange(list);
With list being a List<string>.
Sometimes it helps to use real world examples:
Every Porsche ( => ApplicationNamesList) is a car ( => List<string>). But not every car is a Porsche.