C
C#9mo 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 User9mo ago
Message Not Public
Sign In & Join Server To View
futuremapper
futuremapper9mo ago
collection spreads are coming in c# 12. maybe you could make a feature request?
333fred
333fred9mo 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
futuremapper9mo ago
😔
Accord
Accord9mo 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.