All Questions
Tagged with namedtuple c#
9
questions
0
votes
1
answer
286
views
Use Tuple values in Object initalizer syntax
I'm trying to initialize properties of an object I am creating with the values of a named tuple.
Something like this
public Person DoIt() {
return new Person {
(First, Last) = GetFirstAndLast(id)...
2
votes
2
answers
215
views
Not able to add value to List of named tuple
I have a named List of named tuple and from this function OnEndCircularReferencesCalculation()
I am trying to add value to named tuple but getting error message like : 'Index was out of range. Must be ...
1
vote
1
answer
406
views
Converting Python tuple to C#
I am in the process of converting a program from Python to C#. I'm about 80% there, but I came across this code in Python and I am not sure exactly how this would translate over to C#:
from typing ...
2
votes
1
answer
3k
views
API call with named tuple as input parameter [duplicate]
One of my API endpoints expects a object containing a list of named tuples. An example of the input object would be:
public enum Countries { Afghanistan, Albania, Algeria, Andorra /*...*/ }
public ...
0
votes
0
answers
29
views
How can you name a tuple used as a function parameter in C#? [duplicate]
I want to use a tuple as an input argument for my function.
public void Sync(IEnumerable<Tuple<string, double>> labels)
But I also want to give the string and double a name. But I can't ...
0
votes
1
answer
1k
views
How do I correctly assign names to a named tuple in a list
I have the following code and it seems to work fine, but when I inspect the tuples inside the list they are named Item1,Item2,Item3 instead of the names I have assigned to them. What am I doing wrong?
...
1
vote
1
answer
1k
views
How to map request payload to Tuple in asp.net core [duplicate]
Below is my endpoint
// D - Delete
[HttpPost,HttpDelete]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public async Task<IActionResult> Delete([FromBody](int eventId, int personId, ...
1
vote
1
answer
590
views
Possible create named tuple type using reflection?
I can create a normal tuple type with Tuple.Create or typeof(Tuple<,>).MakeGenericType etc, but how can I make a named tuple? With other property names than Item1, Item2 etc, using reflection in ...
0
votes
0
answers
726
views
Is there a way to use Pattern Matching in switch statement with Named Tuples?
Let's have the below class
public void HandleMessage(object message)
{
switch (message)
{
case string bookTitle:
Console.WriteLine($"Received book with ...