var$n=value
is not a valid way of assigning to a dynamically created variable name in any shell.
Please use one of the other methods to assign to names via expanded strings.
Wooledge BashFaq #6 has significantly more information on the subject.
n=1
var$n="hello"
n=1
var[n]="hello"
echo "${var[n]}"
typeset -A var
n="greeting"
var[$n]="hello"
echo "${var[$n]}"
declare
:n="Foo"
declare "var$n=42"
echo "$varFoo"
sh
, with single line contents, consider read:n="Foo"
read -r "var$n" << EOF
hello
EOF
echo "$varFoo"
or with careful escaping, use eval
:
n=Foo
eval "var$n='hello'"
echo "$varFoo"