# How do you access a struct field name in a string

**URL:** <https://discourse.julialang.org/t/how-do-you-access-a-struct-field-name-in-a-string/60666>\
**Category:** General Usage\
**Created:** [May 6, 2021, 4:09pm UTC](https://discourse.julialang.org/t/how-do-you-access-a-struct-field-name-in-a-string/60666 "2021-05-06T16:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon60034542](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@anon60034542](https://discourse.julialang.org/u/anon60034542)\
**Post date:** [May 6, 2021, 4:09pm UTC](https://discourse.julialang.org/t/how-do-you-access-a-struct-field-name-in-a-string/60666/1 "2021-05-06T16:09:59Z")

</div>

Suppose I had the follow `struct`:

```julia
struct Employee
	ID::Int32
	name::String
end

```

Is it possible to access a field name while embedded in a string?

```julia
svetlana = Employee(1,"Queen Svetlana")
# prints Employee Name: svetlana.name
println("Employee Name: svetlana.name") 

svetlana = Employee(1,"Queen Svetlana")
# prints #Employee Name: Employee(1, "Queen Svetlana").Queen Svetlana
println("Employee Name: $svetlana.$name") 

```

The only workaround I know of is to store it first in a variable and then embedded it in a string:

```julia
name = svetlana.name
# prints Employee Name: Queen Svetlana
println("Employee Name: $name") 

```

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [May 6, 2021, 4:11pm UTC](https://discourse.julialang.org/t/how-do-you-access-a-struct-field-name-in-a-string/60666/2 "2021-05-06T16:11:30Z")

</div>

Use parenthesis:

> [@anon60034542](#):
>
> "`$(svetlana.name)"`
