Click here to Skip to main content
15,798,111 members
Home / Discussions / C#
   

C#

 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
jschell15-Jun-23 3:47
jschell15-Jun-23 3:47 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
trønderen15-Jun-23 5:15
trønderen15-Jun-23 5:15 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Dave Kreskowiak15-Jun-23 8:38
mveDave Kreskowiak15-Jun-23 8:38 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Richard Andrew x6415-Jun-23 15:56
professionalRichard Andrew x6415-Jun-23 15:56 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
jschell16-Jun-23 10:58
jschell16-Jun-23 10:58 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
trønderen19-Jun-23 9:48
trønderen19-Jun-23 9:48 
QuestionReferencing an Array from another Class Pin
Member 1602947114-Jun-23 6:44
Member 1602947114-Jun-23 6:44 
AnswerRe: Referencing an Array from another Class Pin
OriginalGriff14-Jun-23 7:00
mvaOriginalGriff14-Jun-23 7:00 
Your array creating won't work - it creates an empty array (no elements) and an array can't be expanded or contracted.

Try doing the Sectionquery creating outside the PostSections instance creation: otherwise it gets confusing. The way I'd do it is to replace the array with a list to be more flexible:
C#
internal class PostSections
{
    public string title { get; set; }
    public string[] highlight { get; set; }
    public string[] highlight2 { get; set; }
    public bool highlightFirstWord { get; set; }
    public bool sendToValidation { get; set; }
    public string startDate { get; set; }
    public string endDate { get; set; }

    public List<Sectionquery> sectionQueries { get; set; }
}
That way, you can start by declaring the collection:
C#
var queries = new List<Sectionquery>()
And add your new items to it (even from a JSON / XML / CSV file or a database) without knowing in advance how many elements it needs.

Then just add your new items to it:
C#
queries.Add(new SectionQuery() { ... });
queries.Add(new SectionQuery() { ... });
...
And then change your PostSection instance creation to suit:
C#
var newPost = new PostSections()
     {
         title = "Title of Book",
         highlight = list.ToArray(),
         highlight2 = list.ToArray(),
         highlightFirstWord = false,
         sendToValidation = false,
         startDate = "2022-11-22T00:00:00.000Z",
         endDate = "2022-11-22T00:00:00.000Z",

         sectionQueries = queries
     };
Make sense?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

AnswerRe: Referencing an Array from another Class Pin
jschell14-Jun-23 7:11
jschell14-Jun-23 7:11 
QuestionHow to use switch case instead of if statements? Pin
Member 1405587912-Jun-23 1:28
Member 1405587912-Jun-23 1:28 
AnswerRe: How to use switch case instead of if statements? Pin
Richard Deeming12-Jun-23 2:06
mveRichard Deeming12-Jun-23 2:06 
AnswerRe: How to use switch case instead of if statements? Pin
jschell12-Jun-23 12:09
jschell12-Jun-23 12:09 
QuestionClean code in C# development Pin
WeiminYu10-Jun-23 19:27
WeiminYu10-Jun-23 19:27 
AnswerRe: Clean code in C# development Pin
OriginalGriff10-Jun-23 19:31
mvaOriginalGriff10-Jun-23 19:31 
GeneralRe: Clean code in C# development Pin
Richard Andrew x6411-Jun-23 8:17
professionalRichard Andrew x6411-Jun-23 8:17 
GeneralRe: Clean code in C# development Pin
OriginalGriff11-Jun-23 9:32
mvaOriginalGriff11-Jun-23 9:32 
GeneralRe: Clean code in C# development Pin
trønderen11-Jun-23 12:20
trønderen11-Jun-23 12:20 
QuestionGetting Google Contacts Pin
Kevin Marois6-Jun-23 17:46
professionalKevin Marois6-Jun-23 17:46 
AnswerRe: Getting Google Contacts Pin
OriginalGriff6-Jun-23 19:47
mvaOriginalGriff6-Jun-23 19:47 
GeneralRe: Getting Google Contacts Pin
Kevin Marois7-Jun-23 6:51
professionalKevin Marois7-Jun-23 6:51 
AnswerRe: Getting Google Contacts Pin
Richard MacCutchan6-Jun-23 23:02
mveRichard MacCutchan6-Jun-23 23:02 
GeneralRe: Getting Google Contacts Pin
jschell7-Jun-23 6:19
jschell7-Jun-23 6:19 
GeneralRe: Getting Google Contacts Pin
Richard MacCutchan7-Jun-23 6:42
mveRichard MacCutchan7-Jun-23 6:42 
GeneralRe: Getting Google Contacts Pin
Kevin Marois7-Jun-23 6:53
professionalKevin Marois7-Jun-23 6:53 
GeneralRe: Getting Google Contacts Pin
Richard MacCutchan7-Jun-23 7:09
mveRichard MacCutchan7-Jun-23 7:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.