int x = 1 + 2; var model = compilation.GetSemanticModel(syntaxTree); var constantValue = model.GetConstantValue(x); if (constantValue.HasValue) { Console.WriteLine(constantValue.Value); // 3 } string s = "hello"; var model = compilation.GetSemanticModel(syntaxTree); var constantValue = model.GetConstantValue(s); if (constantValue.HasValue) { Console.WriteLine(constantValue.Value); // "hello" } const int y = 42; var model = compilation.GetSemanticModel(syntaxTree); var constantValue = model.GetConstantValue(y); if (constantValue.HasValue) { Console.WriteLine(constantValue.Value); // 42 }In these examples, we create a `SemanticModel` object and use it to retrieve the constant value of a variable or expression. We then check if the value is present using the `HasValue` property of the `Nullable