Making player.Position a single line?Solved

First of all "Thanks" for the help so far!!

I have the timer creating a new entry in the JSON file (like below) for each event

"76561############ 10/22/2020 09:56:15 ": {
"X": 1475.32312,
"Y": 20.29156,
"Z": 1231.18066
},

It comes from this code:

DateTime dt = DateTime.Now;
dataFile[player.Id + " " + dt + " "] = player.Position();
dataFile.Save();

How do I convert the player.Position() into something that I can insert into the square bracket portion of the dataFile statement?

My objective is for all of this to be on one line.

Thanks!

I'm not sure what you want exactly, but here are some examples of string interpolation and combining variables:
var pos = player.Position();
dataFile[$"player.Id {DateTime.Now}"] = $"{pos.X}, {pos.Y}, {pos.Z}";​

dataFile[$"player.Id {DateTime.Now}"] = player.Position();​

var pos= player.Position();
dataFile[$"player.Id {pos.X}, {pos.Y}, {pos.Z}"] = player.Id;

var pos= player.Position();
dataFile[$"{pos.X}, {pos.Y}, {pos.Z}"] = DateTime.Now;​
Wulf,

I think this is what I was looking for.

Will try it today.

Thanks!
Locked automatically