I want to see if there is a difference in age structure between male and female fish so I have ages from 0.5 to 8.5 and the number of each sex at that age but I dont know which variables I use in the chi squared
Your categorical variable sex is the 'independent' variable. With the chi-square test, one usually calls this the 'association' variable. (One does not call it the independent causing variable.) Such a test is for the association between variables. In your case between sex and ages. You will have to categorize ages in a number (say some 5) of categories.