C
C#15mo ago
CrosRoad95

❔ Spread like operator in blazor

i have some .razor component accepting class, but i would like to pass individual parameters to it, let's say:
public class Foo{
public string Test1 {get;set;}
public string Test2 {get;set;}
}

// and my .razor component:
Foo fooClass = new();
<MyComponent ...fooClass />

MyComponent:
@code
{
[Parameter]
public string Test1 {get;set;}
[Parameter]
public string Test1 {get;set;}
}
public class Foo{
public string Test1 {get;set;}
public string Test2 {get;set;}
}

// and my .razor component:
Foo fooClass = new();
<MyComponent ...fooClass />

MyComponent:
@code
{
[Parameter]
public string Test1 {get;set;}
[Parameter]
public string Test1 {get;set;}
}
is it possible? to use ... spread operator?
5 Replies
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
futuremapper
futuremapper15mo ago
collection spreads are coming in c# 12. maybe you could make a feature request?
333fred
333fred15mo ago
We'd be pretty unlikely to make an operator like that C# doesn't have js-like object spreading in this fashion, and adding a meta-feature like this outside C# contexts doesn't really fit well with razor's philosophies
futuremapper
futuremapper15mo ago
😔
Accord
Accord15mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server