.NET 6-0 -new List 'new' expression can be simplified

Created at 08 Apr 2023, 14:39
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CT

ctid5083541

Joined 25.05.2022

.NET 6-0 -new List 'new' expression can be simplified
08 Apr 2023, 14:39


I get the  'new' expression can be simplified to the following line of code:

private List<double> myPrices = new List<double>();

It works fine in .NET Framework 4x (Legacy) but I want my code to work in .NET 6.0 as well.

How do I resolve this?

Any help appreciated.

Many thanks.


@ctid5083541
Replies

firemyst
09 Apr 2023, 07:19

RE:

ctid5083541 said:

I get the  'new' expression can be simplified to the following line of code:

private List<double> myPrices = new List<double>();

It works fine in .NET Framework 4x (Legacy) but I want my code to work in .NET 6.0 as well.

How do I resolve this?

Any help appreciated.

Many thanks.

You don't have to. It can be simplified doesn't mean it has to be simplified.

If you simplify it, the syntax may not be compatible with .net framework 4.x.

If you are using Visual Studio, just hover the issue in the actual code and then in the pop up window select "show potential fixes".


@firemyst

ctid5083541
17 Apr 2023, 15:56

RE: RE:

No I don't have Visual Studio but thanks for your reply.

 

firemyst said:

You don't have to. It can be simplified doesn't mean it has to be simplified.

If you simplify it, the syntax may not be compatible with .net framework 4.x.

If you are using Visual Studio, just hover the issue in the actual code and then in the pop up window select "show potential fixes".

 


@ctid5083541